 Last Updated:

# C program to find sum and average of n numbers stored in an array ## Algorithm

Input: Input size of the array and elements of the array
output: Displays the sum and average of input elements

1. Start
2. Input the size of the array say n and enter the elements of the array a[n]
3. i = 0
4. sum = 0
5. while ( i<n )
5.1 sum = sum + a[ i ]
5.2 i++
6. print " The sum of elements in the array is " sum
7. avg = sum / n
8. print "The avg of elements in the array is " avg
9. stop

## C Program #include <stdio.h>
int main()
{
int n;
float avg,sum=0;
printf("Enter the size of array: ");
scanf("%d", &n);
float a[n];
printf("Enter the elements one by one\n");
for (int i = 0; i<n; i++) {
scanf("%f", &a[i]);
}
for (int i = 0; i<n; i++) {
sum = sum + a[i];
}
printf("The sum of the array is %f \n", sum);
avg = sum / n;
printf("The average of the array is %f", avg);
}

Note: This Program was created using visual studio code. The Program file can be downloaded by clicking here

## Flowchart

Note: This Flowchart was created using a program called Raptor. The flowchart file can be downloaded by clicking here