Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
|
Privacy
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
Please
log in
to post a comment.
PreprocessorVsNamespace
timeConversion
Compile time creation of class member stl container (const std::array) filled with elements.
problem_solution5
define own struct
program_solution_3
Sorting algorithm comparison
xxx
throwing Copyable versus throwing MoveOnly
multiplie linked list numbers
Please log in to post a comment.