Output:
Enter 5 Elements:
1
2
3
4
5
Sum is 15
Average is 3
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
Enter 5 Elements:
1
2
3
4
5
Sum is 15
Average is 3
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5,i,a[5],sum=0;}
clrscr();
for(i=0;i<n;i++)
{
printf("Enter the a[%d]",i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("The sum of array is %d",sum);
printf(\n"Average is %f",(float)sum/n);
getch();
No comments:
Post a Comment