c 2b 2b calorie calculator using a for loop

Solutions on MaxInterview for c 2b 2b calorie calculator using a for loop by the best coders in the world

showing results for - "c 2b 2b calorie calculator using a for loop"
Liah
17 Jun 2020
1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7    int numberOfItems;
8    int totalCalories = 0;
9    int caloriesForItem;
10    cout << "How many items did you eat today? ";
11    cin >> numberOfItems;
12    cout << "Enter the number of calories in each of the "
13         << numberOfItems << " items eaten:  " << endl;
14
15    for (int count = 1; count <= numberOfItems; count++)
16    {
17        cout << "Enter calorie: ";
18        cin >> caloriesForItem;
19        totalCalories += caloriesForItem;
20    }
21
22    cout << "Total calories eaten today = " << totalCalories;
23
24    return 0;
25}