In this tutorial, we are going to learn a writing program in the C Programming language to find the Average of numbers.
This is How our program will behave
1). At first Our C Program will take the total count for the numbers for which we want to calculate the average.
2). After taking the count, We have to give the number to calculate the average.
3). Here we are considering input value as Integer and output may be an integer or float value.
What is the average number?
Average is a mathematical calculation that can be obtained by the sum of numbers divided by the total count of the numbers.
For example
Suppose we want to calculate the Average of 1,2,3,4,5
So, first, find the sum of all numbers
1+2+3+4+5 = 15
And here total count for the numbers is 5.
So Average will be 15/5 = 3
C Program to Calculate the average of numbers using for loop
#include<stdio.h>
void main() {
int n, i;
float num, average, sum = 0;
printf("Enter the value of n:");
scanf("%d", & n);
for (i = 1; i <= n; i++) {
printf("Enter the %d number: ", i);
scanf("%f", & num);
sum += num;
}
average = sum / n;
printf("\nTotal Average is = %1.2f\n ", average);
}
Output

C Program to calculate the average of numbers Using while loop
#include<stdio.h>
#include<conio.h>
void main() {
int n, i = 1;
float num, average, sum = 0;
printf("Enter the value of n:");
scanf("%d", &n);
while (i <= n) {
printf("Enter the %d number: ", i);
scanf("%f", &num);
sum += num;
i++;
}
average = sum / n;
printf("\nTotal Average is = %1.2f\n ", average);
}
Output 1:

Also Prepare Below Important Question
- Python Program to add two number using Recursion
- Python Program to Find Highest Frequency Element in Array
- Python Program to Merge two Arrays
- Perform left rotation by two positions in Array Using Python
- Python Program to Delete Element at Given Index in Array
- Python Program to Delete element at End of Array
- Python Program to Copy one String to Another String
- Python Program to Remove Repeated Character from String
- Print highest frequency Character in String in Python
- Python Program to Convert lowercase vowel to uppercase
- Convert Celsius to Fahrenheit in Python
- Leap Year Program in Python
- Python Program to convert Decimal to Octal number
- Python Program to Convert Decimal Number into Binary
- Find all Pairs Whose Sum is Equal to Given number in Python
- Python Program to Replace First Vowel With ‘-‘ in String
- Python Program to find Prime factors of given integer
- Python Program to Print Prime Number in given range
- Java Program to Perform Left Rotation on Array Elements by Two
- Java Program to Perform Right Rotation on Array Elements by Two
Interview Questions Categories
C Programming Interview Preparation
Core Java Programming Interview Preparation
- Core Java Programming Coding Questions
- Core Java Pattern Programming Questions
- Core Java Programming Interview Questions