0 votes
299 views
in C programming by (98.9k points)
edited
Write a program to accept ‘n’ integer from user into an array and
display them in one each line.

1 Answer

0 votes
by (98.9k points)
selected by
 
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();
 }

 

Related questions

0 votes
1 answer 228 views
0 votes
1 answer 121 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

558 users

...