-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhile.cpp
35 lines (26 loc) · 830 Bytes
/
While.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream> // sends text to and from the console
using namespace std; // we hate typing 'std::' all the freaking time.
int main() {
cout << "Hello World!\n";
cout << "I am thinking of a number between 1 and 10. Can you guess it?\n";
// set it up at the top of the code
int theNumber = 4;
int playerGuess = 0; // just good practice to define all variables when created.
//int num = 0;
cout << "Your guess: ";
cin >> playerGuess;
//cout << "\nnum: ";
// cin >> num;
// a single equals is an assignment, a double equals is a comparison.
// a single equals is "You are...", a double equals is "Are you?"
while(true)
{
if (playerGuess == theNumber)
{
cout << "\nThere you go !!....\n";
}
else {
cout << "Nope nope !!!....";
}
}
}