
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.
WRITE A C PROGRAM:
//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();
}
#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();
}
No comments:
Post a comment
Note: only a member of this blog may post a comment.