First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

Write a program to accept ‘n’ integer from user into an array and display them in one each line.

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,a[100],sum=0;
float avg;
clrscr();
printf("Enter the number of elements:");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
    printf("Enter a value:");
    scanf("%d",&a[i]);
}
for(i=0;i<=n-1;i++)
{
    sum=sum+a[i];
}
avg=sum;
avg=avg/n;
printf("The average of the numbers entered is %f",avg);
getch();
 }
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...