MIS 24053 Lecture 10: do-while statement
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 "