This C program will let you know about “Calculating the Sum and Average of N numbers using array technique“. This simple C source code is coming under the part of C beginners guide.
SUM AND AVERAGE - ARRAY OF NUMBERS IN C
Sum and average the array of numbers in C program is used calculate the average and sum values of a student marks by using for loop statement. It will execute until the all array of numbers will be calculated and average will be displayed.
[Useful: Education Loan Guide] & [Study Abroad Details]
WRITE A C PROGRAM:
/* Title: Sum & Average of N numbers
Author: Vinoth Selvaraj
© http://students3k.com
*/
//Header files
#include<stdio.h>
#include<conio.h>
void main()
{
//Program variables
int b[10],j,sum=0;
float av;
clrscr(); //Function to clear previous output
for(j=1;j<=10;j++) //looping statement
{
printf("ENTER THE %d NUMBER:--" ,&j); //Display function
scanf("%d",&b[j] ); //Getting input function
}
for(j=1;j<=10;j++)
printf("\nthe numbers are %d",b[j]);
for(j=1;j<=10;j++)
sum=sum+b[i];
printf("\n THE SUM OF NUMBERS ARE: %f",sum);
av=sum/10;
printf("\n THE AVERAGE OF NUMBERS R:%2.2f",av);
getch();
}