Answer to Question #291262 in C for Pacan

Question #291262

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.

1
Expert's answer
2022-01-27T07:46:33-0500
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS