Vishal is having a bunch of coins ranging from rupees 1 to 10. Help him to write program to find the sum and average of the coins that he is having using while loop.
#include <stdio.h>
void main() {
int i=1, sum = 0;
float avg;
while(i <= 10) {
sum += i;
i++;
}
avg = sum / 10.0;
printf("The sum of 10 coins is : %d\nThe Average is : %f\n", sum, avg);
getchar();
getchar();
}
Comments
Leave a comment