Basic C Program Examples

C Program Examples
C Program to Check number is Odd or Even
C Program to Check number is Odd or Even

In this program, User Enter a number and check whether the given number is even or odd. Then, after successful compilation displays to check it is Odd or Even on the screen. The output of this Program is given below:Enter any number to check it is even or odd: 4153 is Even.Enter any number to check it is even or odd: 33 is Odd.

C Program Examples
C program to convert celsius to fahrenheit
C program to convert celsius to fahrenheit

To get the output of the this Program, User will Enter temperature in Celsius: 100 Then, Compiler will convert it into Fahrenheit automatically. The final output shown onto the screen is as follows: Enter temperature in Celsius: 100 100 Celsius = 212.00 Fahrenheit

C Program Examples
C program to find area of rectangle
C program to find area of rectangle

In this Program, User will enter the length and width of the rectangle into two variables length and width. Then, Calculating the Area of the rectangle using the formula Area = length × width. After the successful execution the final area of a rectangle is shown on screen.

C Program Examples
C program to find area of triangle
C program to find area of triangle

In this Program, User will enter the three sides of the triangle a, b, c. Then, Calculating the Perimeter of the Triangle. Moreover, calculating the semi perimeter using the formula (a + b + c) / 2 and calculating the Area of a triangle using Heron’s Formula: sqrt(s * (s - a) * (s - b) * (s - c)). After the successful execution of the program the final area of a triangle is shown on screen.

C Program Examples
C Program to find largest number among three numbers
C Program to find largest number among three numbers

In this program, three numbers are assigned in to the three variables one by one. Then, compare the two selected of them with the use of comparison operator. Repeat the same process for the other two. After the successful execution of the program the final largest number amongst the three are displayed on the screen.

C Program Examples
C program to get length of string
C program to get length of string

In this program, using a for loop, we have iterated over characters of the string from i = 0 to until '\0' (null character) is encountered. In each iteration, the value of i is increased by 1. When the loop ends, the length of the string will be stored in the i variable.

C Program Examples
C program to check number is armstrong
C program to check number is armstrong

In this program, the number of digits of an integer is calculated first and stored in n. And, the pow() function is used to compute the power of individual digits in each iteration of the second for loop.

C Program Examples
C program to generate multiplication table
C program to generate multiplication table

After the successful compilation of the program, In this program, we used two variables num, and i. The variable num is used to store the input integer number and the variable ‘i’ is used to iterate the loop. Product of the number is given by num*i;

C Program Examples
C program quadratic equation
C program quadratic equation

After the successful compilation of the program, this program displays the following output: Enter values for a, b, c of quadratic equation ax2+bx+c are: If user enters 1, 2, 6 then it displays two distinct complex roots exists: -1.00 + i2.24 and -1.00 - i2.24

C Program Examples
C program to check perfect number
C program to check perfect number

Perfect number is a positive integer which is equal to the sum of its proper positive divisors. After the successful compilation of the program, this program displays the following output: Enter any number to check perfect number: If user enters 6 then it displays a message like 6 is a perfect number.

Write For Us.

Contribute the Community.