- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSum_Average_Array.cpp
More file actions
Latest commit
20 lines (18 loc) · 563 Bytes
/
Copy pathSum_Average_Array.cpp
File metadata and controls
20 lines (18 loc) · 563 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<conio.h>
voidmain()
{
int i, no_terms, a[10], sum = 0;
float average;
printf("Enter the Number of Elements of the Array :: ");
scanf_s("%d", &no_terms); /*No of Elements */
printf("\nEnter the Elements of the Array :: ");
for (i = 0;i < no_terms;i++)
scanf_s("%d", &a[i]);
for (i = 0;i < no_terms;i++)
sum += a[i];
average = (float)sum / no_terms;
printf("\nThe Sum of the Elements of the Array is :: %d", sum);
printf("\nThe Average of the Elements of the Array is :: %.2f", average);
_getch();
}