Answered step by step
Verified Expert Solution
Link Copied!

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'. #include  using 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions