Finding avarage using array:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
float avg,sum=0;
float arr[50];
printf("How many number you will take for avarage calculation:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("arr[%d]=",i+1);
scanf("%f",&arr[i]);
sum=sum+arr[i];
}
avg=sum/n;
printf("Avarage is %f",avg);
getch();
}
No comments:
Post a Comment