# C program to find the average of N numbers by using for loop

ADVERTISEMENTS

C program to find the average of N numbers by using for loop. In this program, you'll learn how to count the average of N input numbers by using for loop.

Let us consider an example to understand this through a c program:

```
// C program to find the average of N numbers by using for loop
#include <stdio.h>
int main() {
int x, i;
float avg = 0, y;
// x - denotes number of elements
// avg - denotes total average value
// y - denotes total input numbers
printf("Enter the number of elements to calculate average::\n");
scanf("%d", &x);
printf("Enter %d elements one by one\n\n", x);
for(i = 0; i < x; i++) {
scanf("%f", &y);
avg += y;
}
avg /= x;
printf("\nThe average of the entered input numbers is = %f", avg);
return 0;
}
```

**Output:**

Enter the number of elements to calculate average::

4

Enter 4 elements one by one

646

642

656

435

The average of the entered input numbers is = 594.750000

## Tags:

1. C program to find average of n numbers using the array

2. C program to find average of 5 numbers

3. Write a program to calculate the average of n numbers in python

4. C program to find average marks of 30 students