Do-While Statement
/* * This program makes you say "cheese" */ #include <iostream> #include <string> int main() { // Repeated ask the user to say cheese until s/he does. std::string input; do { std::cout << "Please say \"cheese\": "; std::cin >> input; } while(input != "cheese"); // Appreciate the user's kindness. std::cout << "Thank you for saying \"" << input << "\"." << std::endl; }
This loop is always entered the first time.