C Online Compiler
Example: C program to find average of N numbers using Functions
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to find average of N numbers using Functions #include <stdio.h> // This function will find the average of N numbers void FindAverage(int size) { float avg = 0, y; // To store the total average value printf("\nEnter %d elements one by one::\n", size); for(int i = 0; i < size; i++) { scanf("%f", &y); avg += y; } avg /= size; printf("\nThe average of the entered input numbers is = %f\n", avg); } // It's the driver function int main() { int x; // To store the number of elements printf("Enter the number of elements to calculate average::\n"); scanf("%d", &x); FindAverage(x); return 0; }
3 23 45 87
Output
Clear
ADVERTISEMENTS