Write a program in c which will calculate average of all values an array
#include<stdio.h>
#include<conio.h>
main()
{
int a[100],i,sum=0,average=0,n;
printf("\n\tIT'S A PROGRAM TO CALCULATE AVERAGE FROM AN ARRAY\n");
printf("\n\tEnter the array size: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter the %d value: ",i);
scanf("%d",&a[i]);
sum+=a[i];
average=sum/a[i];
}
printf("\n\tThe average is:");
printf("%d\n",average);
}
#include<stdio.h>
#include<conio.h>
main()
{
int a[100],i,sum=0,average=0,n;
printf("\n\tIT'S A PROGRAM TO CALCULATE AVERAGE FROM AN ARRAY\n");
printf("\n\tEnter the array size: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter the %d value: ",i);
scanf("%d",&a[i]);
sum+=a[i];
average=sum/a[i];
}
printf("\n\tThe average is:");
printf("%d\n",average);
}
Not So Bad..Hope you will be continue.
ReplyDelete