76 338
Assignments Done
Successfully Done
In May 2019

Answer to Question #3165 in C++ for fmn

Question #3165
Write a c program that will ask the user how many items he has eaten today and he should ask the user to enter the calories for each of the item and then display the total calories consumed. Write this program using a while loop.
Expert's answer
#include <stdio.h>
int main()
& int i,n;
& float total_calories, calories;
& printf("Please enter how many items your have eaten today = ");
& scanf("%d",&n);
& i=0;
& total_calories=0;
& while (i<n)
& {
& printf("Please enter calories for item %d: ", i+1);
& };
printf("The total calories is %g", total_calories);

return 0;

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions