/*A PROGRAM TO GET SUM OF ALL ELEMENTS IN ARRAY & ALSO FIND ITS AVERAGE VALUE */
#include<stdio.h>
int main()
{
float avg=0;//AVG VALUE IN FLOAT IS 0 IN ORIGINALLY
int arr[10],sum=0;//SUM IS ALSO 0 ORIGINALLY //
int i;
for(i=1;i<=10;i++)//ENTER THE ELEMENTS OF ARRAY INTO LOOP ONE BY ONE//
{
printf("ENTER THE ARR[I]");
scanf("%d",&arr[i-1]);//PUT THE VALUE INTO ARRAY FROM 0TH PSITION ....BUT THIS WILL BE 1ST ELEMENT..//
sum=sum+arr[i-1];//ADD ALL THE ELEMENTS OF ARRAY EVERYTIME IN THE LOOP & PLACE SUM INTO SUM NAMED VARIABLE//
}
printf("sum=%d\n",sum);//AS SUM IS PRINTED
avg=sum/(i-1);//DIVIDE SUM BY NUMBER OF ELEMENTS WHICH ARE 1 LESS THAN ORIGINAL VALUE OF I BCZ..LAST TIME WHEN CONDITION BECOMES FALSE I ++MENTS ONCE MORE....BUT NOT 2 LESS...BCZ.0TH ELEMENT SHOULD ALSO BE COUNTED..//
printf("avg=%f\n",avg);//PRINT AVG VALUE OF SUM OF ELEMENTS OF ARRAY