MIS 24053 Lecture 10: do-while statement

21 views2 pages

Document Summary

How it works: execute action if condition is true then execute action again repeat this process until condition evaluates to false. action is either a single statement or a group of statements within braces. N! int number, factorial, counter; cout << "enter a positive integer:"; cin >> number; }while(counter <= number); factorial = 1; counter = 1; do{ factorial *= counter; counter++; cout << "the factorial of " << number. << " is " << factorial << endl; int number, result, counter; cout << "enter a positive integer:"; }while (counter <= number); result = 1; counter = 1; do{ result *= 2; counter++; cout << "two raised to the " << number. << " power is " << result << endl; << "(-1 to stop):"; cin >> value; if(value > max) cout << "enter a positive number . // maximum value max << endl; max = value; }while(value!=-1); cout << "the maximum value found is "

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents