Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ calorie calculator using a for loop

#include <iostream>

using namespace std;

int main()
{
    int numberOfItems;
    int totalCalories = 0;
    int caloriesForItem;
    cout << "How many items did you eat today? ";
    cin >> numberOfItems;
    cout << "Enter the number of calories in each of the "
         << numberOfItems << " items eaten:  " << endl;

    for (int count = 1; count <= numberOfItems; count++)
    {
        cout << "Enter calorie: ";
        cin >> caloriesForItem;
        totalCalories += caloriesForItem;
    }

    cout << "Total calories eaten today = " << totalCalories;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: thread group c++ 
Cpp :: how to define global array in c++ in a scope 
Cpp :: Arduino Access Point ESP8266 
Cpp :: 12 to december in c++ code 
Cpp :: get player pawn 
Cpp :: inverse elment of array c++ 
Cpp :: namespace c++ 
Cpp :: lambda - print-out array and add comment 
Cpp :: polymorphism c++ virtual 
Cpp :: get array size 
Cpp :: _ZNSolsEi 
Cpp :: what is the format specifier for dword c++ 
Cpp :: inversed priority queue 
Cpp :: int a=0; int b=30; 
Cpp :: c++ max 
Cpp :: while loop in c++ 
Cpp :: Determine if map contains a value for a key c++ 
Cpp :: modify value in map c++ 
Cpp :: assignment operators 
Cpp :: Come concatenare stringhe in c++ 
Cpp :: sinonimo de tratar 
C :: reset style matplotlib 
C :: get pid c 
C :: transpose of matrix using c program 
C :: come creare variabili casuali in c 
C :: multiplication table using c 
C :: multiplication of two matrix in c 
C :: lldb set breakpoint function name 
C :: armstrong number in c 
C :: sequelize count multiple associations 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =