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
assaa
MSVC-IsBaseOf
hangman
accessing private of different type of template
Sum of numbers in a series using sum formular
additional layer of indirection
VC++ windows exception
Matrix paths right-down only, going through XY
constexpr internal error
Get parameter type