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.
1
Expert's answer
2011-06-20T12:12:05-0400
#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); scanf("%g",&calories); total_calories+=calories; i++; & }; printf("The total calories is %g", total_calories);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment