#include<conio.h>
int main()
{
int a[100],b[100],temp,i,j,n,sum=0;
float avg;
printf("How many numbers do you want in array:");
scanf("%d",&n);
puts("\nplease enter the number of array:");
for(i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
for(i=1; i<=n; i++)
{
printf("%d",&a[i]);
sum=sum+a[i];
avg=(float)(sum)/n;
}
puts("----------------------");
printf("The sum of the array is:%d",sum);
puts("\n----------------------");
printf("The average of the array is:%.2f",avg);
puts("\n----------------------");
puts("The reversed array is:");
puts("----------------------");
for(i=n; i>=1; i--)
{
printf("%d ",a[i]);
}
return 0;
}
output:
How many numbers do you want in array:5
please enter the number of array:
4 7 9 3 8
----------------------
The sum of the array is:31
----------------------
The average of the array is:6.20
----------------------
The reversed array is:
----------------------
8 3 9 7 4
No comments:
Post a Comment