C++ examples for Statement:while
What is the output from the program: Nested control statements.
#include <iostream> int main(int argc, const char *argv[]) { int passes = 0; int failures = 0; int studentCounter = 1; int result;/*w ww.j av a2 s .co m*/ while (studentCounter <= 10) { std::cout << "Enter result (1 = pass, 2 = fail) "; std::cin >> result; if (result == 1) passes++; else failures++; studentCounter++; } std::cout << "Passed " << passes << "\nFailed " << failures << std::endl; // determine whether more than 8 students passed if (passes > 8) std::cout << "Bonus to instructor!" << std::endl; return 0; }