While User Guilible

This is another simple project using while loops and if statements.

The program continues to ask the user to input a number other than the number equal to the number of tries they’re had. If the user does, they lose. If they are patient for ten tries, they win.

#include <iostream>

using namespace std;

int main() {
 int i = 0;
 int x;

while (i<10 && x!=i-1){
 cout << "Please enter a number!\nAny number...\nNOT "<< i << "!!!\n";
 cin >> x;
 i += 1;

 if (i==10){
 cout << "Wow, you're more patient then I am, you win.";
 cout << "Hey! you weren't supposed to enter " << i-1 << "!";



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s