Write a c program to accept n numbers from user and store these numbers into array and calculate the average of these numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,sum=0;
float avg=0;
int a[100];
float n;
clrscr();
printf("\n enter the limit ");
scanf("%f",&n);
printf("\n enter the array elements \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n  the array elements is \n");
for(i=0;i<n;i++)
{
printf("\n\t%d",a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("\n sum of array elements=%d\n",sum);
avg=sum/n;
printf("\n average=%f",avg);
getch();
}

Comments