Answer to Question #264466 in C for Hari

Question #264466

2. 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.

Solution: 



1
Expert's answer
2021-11-11T07:59:01-0500
 #include <stdio.h>
void main() {   
    int i, sum = 0;
	float avg;
	for (i = 1; i <= 10; i++)	{
		sum += i;
	}
	avg = sum / 10.0;
	printf("The sum of 10 coins is : %d\nThe Average is : %f\n", sum, avg);
}


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