Answered step by step
Verified Expert Solution
Question
1 Approved Answer
// Finish the following program which adds up all integers from 0 to // the user's given number inclusively using a While Loop. The total
// Finish the following program which adds up all integers from 0 to // the user's given number inclusively using a While Loop. The total should be // assigned to the variable 'total'. #includeusing namespace std; int main() { int number; int total = 0; int counter = 0; //initialize the variable // user enters a number cout << "Enter a positive integer to find the summation of "; cout << "all numbers from 0 to the given number up to 100." << endl; cin >> number; // check for invalid user input if (number < 1 || number > 100) { cout << "Invalid Input" << endl; return -1; // terminate program } // TODO - add your code here. // hint: increment a counter variable inside the loop. cout << "Your total is :" << total; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started