C Program to Find Average of 3 Numbers

Calculating the average of numbers is a common operation in programming. In C, you can easily compute the average of three numbers using simple arithmetic operations. Let’s write a simple C program that calculates the average of three given numbers.

c program for average

C Program to find Average of 3 Numbers

Below is a simple C program that takes three numbers as input, computes their average, and displays the result:

Output

c program to find average of 3 numbers

C Program to find Average of 3 Numbers Explanation

  1. Variable Declaration: Three variables (num1, num2, num3) of type float are declared to store the input numbers.
  2. User Input: The program prompts the user to input three numbers using printf() and reads these values using scanf().
  3. Average Calculation: The average of the three numbers is computed by adding them together and dividing the sum by the total count of numbers, which in this case is 3.
  4. Display Output: Finally, the program displays the input numbers along with the computed average using printf().

Calculating the average of three numbers in C involves basic arithmetic operations. By following this simple program structure, we can calculate the average of three given numbers.

See Also

6 thoughts on “C Program to Find Average of 3 Numbers”

Leave a Comment