#include <iostream>
using namespace std; int main( ) { int numberOfItems, count, caloriesForItem, totalCalories; cout << "How many items did you eat today? "; cin >> numberOfItems; totalCalories = 0; count = 1; cout << "Enter the number of calories in each of the\n" << numberOfItems << " items eaten:\n"; while (count++ <= numberOfItems) { cin >> caloriesForItem; totalCalories = totalCalories + caloriesForItem; } cout << "Total calories eaten today = " << totalCalories << endl; return 0; } |
Navid Plus is a Tech blog focusing on Science material that I learn day through my College and job. Most likely, blog posts contain C++ Programming, Security, Networking, and Math. Let's have some fun.
Monday, March 13, 2017
C++ Part 22
While loop Example:
Subscribe to:
Post Comments (Atom)
Digital Design Part 3
4th→ assembler translates it to the machine language. 1.6 [20] <§1.6> Consider two diļ¬erent implementations of the same instru...
-
A statement is an instruction that is executed and typically updates some variable (called a side effect). An expression is something t...
-
Working with String - File - While Loop //NavidPlus.blogspot.com #include <iostream> #include <fstream> #include &l...
No comments:
Post a Comment