21. Write a C program to find the sum and average of different numbers which are accepted by using as many as the user wants
#include<stdio.h> ( this applies in the given code )
#include
int main()
{
int no,sum=0,i=0,val;
printf(“\n How many nos you want to enter : “);
scanf(“%d”,&no);
while(i<no)
{
printf("Enter No [%d]:",i+1);
scanf("%d",&val);
sum=sum+val;
i++;
}
printf("\n Sum = %d",sum);
printf("\n Sum = %.2f",((float)sum)/no);
return 0;
}
OUTPUT
How many nos you want to enter : 2
Enter No [1]:10
Enter No [2]:20