## How do I calculate using loop in C++.

Lets loop by asking a user to enter 10 times the numbers and then the code will calculate them.

Creating a variable landi with the value 1.

int landi = 1;

Now storing the sum variable with default value 0. The sum will calculate and get the total of all entered numbers.

int sum = 0;

Variable numbers for user is input.

int numbers;

Validate while landi less and equal to 10.

landi <= 10;

User is input to enter integers ten times.

cin >> numbers;

The sum variable will add and count each input entered by the user.

sum = sum + numbers;

Increase add by one.

landi ++;

Once the loop ends, calculate and print on the screen.

cout << "The sum of the numbers is: " << sum << endl;

Isn't this the easiest calculator ever? .

Feel free to use the code.

Last update .