• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C » C Control Structures

C calculating Integration using Trapezoidal Rule

By Dinesh Thakur

The trapezoidal rule is the simplest method to approximate the definite integral of a function f(x) over the interval [a, b]. Given N equally space points (with a spacing of h) X0, X1, …, XN such that X0 = a and XN = b, the integral of f(x) can be approximated as the sum. [Read more…] about C calculating Integration using Trapezoidal Rule

C Program for string encryption using Caesar cipher (shift encoding).

By Dinesh Thakur

C program to encrypt text using one of the simplest ciphers known as the “Caesar cipher.” In this encryption scheme, we shift all characters by a given offset. For example, if we use an offset of 4, every occurrence of ‘A’ will be replaced by ‘E’, every occurrence of ‘B’ will be replaced by ‘F’, and so forth. The encrypted text can be decrypted by using the reverse process if know the offset used for the encryption. [Read more…] about C Program for string encryption using Caesar cipher (shift encoding).

C Program for Rational Approximations for Real Numbers

By Dinesh Thakur

The C program computes the rational approximation to a given real number, i.e., given a real number val, the program computes a pair of integers N and D such that the fraction N/D is a good approximation to val. To do so, we use the following series of steps. [Read more…] about C Program for Rational Approximations for Real Numbers

C Program Calculation of Perfect Numbers

By Dinesh Thakur

Perfect numbers are positive integers which have the special property that the sum of all their factors equals the number itself, e.g., 6 = 1+2+3. The C program finds and prints out all perfect numbers less than 1000. [Read more…] about C Program Calculation of Perfect Numbers

C Program for GCD of Two Integers using Euclid’s algorithm

By Dinesh Thakur

The Greatest Common Divisor of two positive integers can be calculated iteratively by the following formula known as Euclid’s algorithm. You can see that this is a recursive definition with GCD(m,n) defined in terms of GCD(n,m%n).

[Read more…] about C Program for GCD of Two Integers using Euclid’s algorithm

C program to sum the series

By Dinesh Thakur

C program to sum the series 1/12+1/22+1/32 [Read more…] about C program to sum the series

C program to sum the series 1+1/2 + 1/3…+ 1/n

By Dinesh Thakur

In this tutorial, we can learn C program to sum the series 1+1/2 + 1/3…+ 1/n. In this c program, we enter a number and and generate the sum of series. [Read more…] about C program to sum the series 1+1/2 + 1/3…+ 1/n

C Program square and cube of first n natural numbers

By Dinesh Thakur

[Read more…] about C Program square and cube of first n natural numbers

C program to calculate tax, given the following conditions

By Dinesh Thakur

In this tutorial, we can learn C program to calculate tax. In this c program, we enter a number and calculate tax with the given following conditions. [Read more…] about C program to calculate tax, given the following conditions

Nested FOR Loops in C

By Dinesh Thakur

Nested for loops have many applications, particularly, in programs dealing with sorting of lists, input/output of multi-dimensional arrays, etc. and also in the evaluation of expressions involving more than one parameter. The code for nested/or loops is given below. [Read more…] about Nested FOR Loops in C

Compound Conditions In For loop in C

By Dinesh Thakur

So far, we have used only one variable in a for loop; however, more than one variable with different end values and with different modes of increments/decrements may also be used. In a compound for expression, the variables may be separated by a comma as illustrated for i and j below. [Read more…] about Compound Conditions In For loop in C

Endless for loop in C

By Dinesh Thakur

In the expression for for loop the inclusion of the expressions are optional. However, two semicolons must be included. An endless for loop may be written as shown below. [Read more…] about Endless for loop in C

Compound Conditions in a While in C

By Dinesh Thakur

The while expression may consist of a single expression (as it is generally done in most of the programs); however, we may also use compound conditions or expressions. Multiple expressions may be connected by a comma operator or by Boolean operators. If the expressions are simply connected by comma, it is the last expression that is evaluated. The expressions preceding the last are ignored. In the following while expression the first expression, i.e., j <4 is neglected. [Read more…] about Compound Conditions in a While in C

Nested While Statements in C

By Dinesh Thakur

There are several situations where more than one parameter need to be varied over a range of values to obtain the desired results. For example, there may be a function having two variables, say x and y and it is desired to evaluate the function for different values of x and y. In such cases, for every value of x the values of y are varied over the range of values of y. This calls for nested while expressions as illustrated below. [Read more…] about Nested While Statements in C

C Program Prints Prime Numbers in a given range m to n

By Dinesh Thakur

The outer for loop is set up to process each number in the given range. Each number is tested within this loop using the simplified code. The break statement’s execution causes the inner for loop to terminate as it is the nearest loop enclosing the break statement. If the inner for loop is entirely executed, i. e., if condition d == num is true, num is printed as a prime number. [Read more…] about C Program Prints Prime Numbers in a given range m to n

break Statement in C Language

By Dinesh Thakur

We have seen that a break statement is usually used in a switch statement after the statements in each case. The execution of such a break statement causes the execution of the switch statement to be terminated and the control to be transferred to the statement following the switch statement. [Read more…] about break Statement in C Language

C Program print a given integer number in words

By Dinesh Thakur

Consider that we wish to print a given positive integer number in words, as a sequence of digit strings. For example, number 123 should be printed as One Two Three. This might be required in financial applications, for example, to print the cheque amount in words. [Read more…] about C Program print a given integer number in words

C Program Print Pythagorean triplets

By Dinesh Thakur

Three positive integer numbers a, band c, such that a<b<c form a Pythagorean triplet if c2= a2 +b2 , i. e,, a, b and c form the sides of a right-angled triangle. To select the values of a and b such that a < b and a, b < max, we can use nested for loops as shown below: [Read more…] about C Program Print Pythagorean triplets

C Program Prime factors of a given number

By Dinesh Thakur

As the name indicates, the prime factors of a given number are its factors that are also prime numbers, e.g., prime factors of 30 are 2, 3 and 5 but not 1, 6, 10, 15 and 30. One or more prime factors of a given number may repeat, e. g., prime factors of 120 are 2, 2, 2, 3 and 5. [Read more…] about C Program Prime factors of a given number

C Program Sum of digits of number repeatedly to obtain a single-digit number

By Dinesh Thakur

The program segment given below determines the sum of digits of a given number repeatedly until a single digit number is obtained. For example, 5985 => 27 => 9, where symbol => indicates a digit sum operation. Thus, if digit sum exceeds 9, it is used as a number for subsequent digit sum operations. [Read more…] about C Program Sum of digits of number repeatedly to obtain a single-digit number

Nested Loops in C

By Dinesh Thakur

The C language provides three loops (for,while and do …while). As contained statement in the body of the loop can be any valid C statement, we can obtain several nested-loop structures by replacing this statement with another loop statement. Thus, if we replace the statement in a for loop with another for loop, we will get a two-level nested for loop as [Read more…] about Nested Loops in C

C Program Data entry Validation

By Dinesh Thakur

The program segment given below reads a number from the keyboard (in variable num of type float) and prints its square root. However, as the sqrt function requires a non-negative argument, the program uses a do ..while loop to read the data until valid data is entered. [Read more…] about C Program Data entry Validation

C Program Count Number of odd and even digits in a given integer number

By Dinesh Thakur

This program segment below uses a straight-forward approach to count the number of odd and even digits in a given integer number(num).

[Read more…] about C Program Count Number of odd and even digits in a given integer number

C Program Four digit special perfect square numbers

By Dinesh Thakur

The program segment given below prints four-digit special perfect square numbers in which the upper and lower two-digit numbers are perfect squares as well. [Read more…] about C Program Four digit special perfect square numbers

C Program Date is Valid or Not

By Dinesh Thakur

Let us use variables dd,mm and yy (all of type int)to represent the day, month and year in a given date. The given date is valid only if year (yy)is non-zero, month (mm)is in the range 1 to 12 and day of month (dd) is in the range 1 to mdays, the number of days in a given month mm. An algorithm to determine the validity of a given date is given below. [Read more…] about C Program Date is Valid or Not

C Program Print Odd Numbers in a given range m to n

By Dinesh Thakur

In this example, a for loop is set up with values of loop variable num from m to n. The if statement is executed for each value of num and if nums an odd number (num%2 equals 1), it is printed using the printf statement. The output of this code is given below for m = 20 and n = 40. [Read more…] about C Program Print Odd Numbers in a given range m to n

C Program Print a comma-separated list of numbers from 1 to 10

By Dinesh Thakur

The if statement within the body of the for loop is used to print a comma after each value of the loop variable except the last one. [Read more…] about C Program Print a comma-separated list of numbers from 1 to 10

What is the difference between IF-ELSE and SWITCH?

By Dinesh Thakur

Both the switch and if-else-if statements enable us to select one of several alternative statements for execution. However, they differ in several aspects: [Read more…] about What is the difference between IF-ELSE and SWITCH?

C Program Examination result in a single subject with data validation

By Dinesh Thakur

The program segment given below accepts marks in a single subject and uses a nested if statement to determine the validity of marks and the result if the value of marks is valid. This code can be written in a more readable form using an if-else-if statement as [Read more…] about C Program Examination result in a single subject with data validation

C Program Character test letter, vowel, consonant

By Dinesh Thakur

The program segment given below uses a nested if statement to determine whether a given character is a letter or not. In addition, if the given character is a letter, it tests whether it is a vowel or consonant. [Read more…] about C Program Character test letter, vowel, consonant

Next Page »

Primary Sidebar

C Programming

C Programming Tutorials

  • C - History
  • C - Anatomy
  • C - Constants
  • C - Identifiers
  • C - Data Types
  • C - Libraries File
  • C - Header Files
  • C - Basic Language
  • C - Data Types Sizes
  • C - Header Files Importance
  • C - Escape Sequences
  • C - Main() Purpose
  • C - Program Procedure
  • C - Control Statements
  • C - Enumeration Constant
  • C - Add numbers
  • C - Return Statement
  • C - Avoid Goto
  • C - Command Line Arguments
  • C - Switch Case
  • C - Switch Case Limitations
  • C - getchar() and putchar()
  • C - Iteration Statements
  • C - Pass by Value and Reference
  • C - Structures and Unions
  • C - Structure
  • C - Dynamic Memory
  • C - Fgets and Fputs Functions
  • C - Gets() and Puts() Functions
  • C - Armstrong Number
  • C - Storage Classes
  • C - Fibonacci Series
  • C - Precision Setting
  • C - const Parameters

C - Variable & It's Type

  • C - Variables
  • C - Variable Lifetime
  • C - Static Variable
  • C - Register Variable
  • C - Global Variables
  • C - Auto Variables
  • C - Local Variables

C - Operator & Expressions

  • C - Operator
  • C - Boolean Operators
  • C - Bitwise Operator
  • C - Arithmetic Operators
  • C - Modulus Operator
  • C - Ternary Operator
  • C - Expressions
  • C - Arithmetic Expressions

C - Array

  • C - Arrays
  • C - Array Types
  • C - Array Characteristics
  • C - Static Arrays
  • C - Global Arrays
  • C - 3D Arrays
  • C - Dynamic Arrays
  • C - Pointer to 3D Arrays
  • C - Array Elements Hold
  • C - Arrays as Function Parameters
  • C - Accessing Matrix Elements
  • C - File Handling
  • C - Matrix Multiplication
  • C - Dynamic Memory Allocation

C - Searching & Sorting

  • C - Data Structures
  • C - Linear Search
  • C - Bubble Sort
  • C - Merge Sort
  • C - Linked List
  • C - Insertion Sort
  • C - Binary Search
  • C - Selection Sort
  • C - Quick Sort

C - Functions

  • C - Functions
  • C - Functions Advantages
  • C - Void Functions
  • C - Function Call
  • C - Default Return Value
  • C - String functions

C - Pointer

  • C - Pointers
  • C - Type Casting Of Pointers
  • C - Pointer Advantages
  • C - Pointers Initialization
  • C - Vectors and Pointers

C - Differences

  • C - C Vs C++
  • C - Formal Args. Vs Actual Args.
  • C - Keywords Vs Identifiers
  • C - Strings Vs Character Arrays
  • C - Address Vs Dereference Operator
  • C - Goto Vs longjmp
  • C - Declaring Vs Defining Variable
  • C - String Vs Array
  • C - Call by Value Vs Reference
  • C - Structure Vs Union
  • C - For Vs While loops
  • C - Compiler Vs Interpreter

C - Programs

  • C Program Standard Deviation
  • C Program Calculate Tax
  • C Program Sum Series
  • C Program Merge Arrays
  • C Program Euclid’s Algorithm
  • C Program Print Weekdays
  • C Program Sum of Digits
  • C Program Print a list
  • C Program Print Pythagorean
  • C Program Quiz program
  • C Program Display Table
  • C Program Print Comma-Separated
  • C Program Prints Prime Numbers
  • C Program for Print Integer
  • C Program Count Number
  • C Program Print Color Name
  • C Program Print Odd Numbers
  • C Program Calculate area
  • C Program for a Menu
  • C Program Add Two Vectors
  • C Program Array Addresses
  • C Program Division by Zero Error
  • C Program Compare two Dates
  • C Program Tower of Hanoi
  • C Program return 3 Numbers
  • C Program for Prime Numbers
  • C Program for Factorial
  • C Program for Palindrome

Other Links

  • C Programming - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW