Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string> //I love strings
- #include <cctype> //I love "C" characters too
- using namespace std;
- //fun with a switch
- int main() {
- //comparing ==, >, < , ! (in C++ = is assignment and == is compare)
- //can combine above such as >= 9greater than or equal to) != (not equals)
- bool keep_going = true;
- string string1 = "Roger";
- string string2 = "";
- do{
- if (string2.empty()) cout << "hint the correct answer is Roger" << endl;
- cout << "Who is the smartest person in the room? [q to quit] ";
- cin >> string2;
- if ( string2 == "q") keep_going = false;
- else {
- if (string1 == string2) cout << "You pass this class\n";
- else cout << "See you next semester\n";
- }
- } while (keep_going);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement