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
Preserving strict aliasing Union example
dharmesh
What exactly is “broken” with Microsoft Visual C++'s two-phase template instantiation?
VS struct_member_name
thread-destructor
Strings
cv4_template
It complies!
seh exception in constructor memory leak
assignment