Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Guess a number in c++
#include <iostream> #include <random> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int number = rand() % 10 + 1; int guess = 0; std::cin >> guess; if(guess == number){ std::cout << "Wow first try!\n"; } else { while(guess != number){ std::cout << "Sorry, " << guess << " is incorrect.\n"; std::cin >> guess ; } } std::cout << "You won! The number was " << number << "."; }
run
|
edit
|
history
|
help
0
Multi Inheritance
Matrix_1
5sdgts
no-thread
operator new / delete
vc++ bug?
Regex failure
#32
Computing factorial of an integer with recursion and iteration
Union and possible undefined behavior