Write a program to ask the user “How many items did you eat today”, and for each item ask the user also “how number of calories in each item” and then calculate the total_calories for each item in one variable then show the result , all that using for loop.
1
Expert's answer
2012-02-23T10:17:19-0500
C++: Write a program to ask the user “How many items did you eat today”, and for each item ask the user also& “how number of calories in each item” and then calculate the total_calories for each item in one variable then show the result , all that using for loop.
#include <iostream.h> & int i,n; float total_calories=0, calories;
void main() { cout<<"How many items did you eat today?"; cin>>n; for (i=1;i<=n;i++){ & cout<<"Enter the item "<<i<<" number of calories:"; & cin>>calories; & total_calories = total_calories + calories; } cout<<"Total calories: "<<total_calories<<"\n"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
I was amazed on the turnaround on not only the work but the response time. There were 4-5 assignments before that began to make me wonder on the customer service aspect and not just the completion of work. This assignment and support brought light at the end of the tunnel.
Comments
Leave a comment