Computer Science, asked by kaushikvidit007, 1 year ago

Write a program to calculate the sum of the array. 23 12 56 76 13 9 45 90 66 100

Answers

Answered by vyomgupta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<stdio.h>
int main( ){
int arr[50],i,sum=0,n;
float avg=0.0;
printf("Enter the number of element U want to enter:");
scanf("%d",&n);
printf("\nEnter %d elements to the array arr:",n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]); //reading the array elements
for(i=0;i<n;i++)
sum=sum+arr[i];
avg = (float)sum/n;
printf("\nThe array elements are:\t");
for(i=0;i<n;i++)
printf("%d\t",arr[i]); //displaying the array elements
printf("\nThe sum of elements =%d",sum);
printf("\nThe average of elements =%f",avg);
return 0;
}
Similar questions