Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Guess a number in c++
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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 << "."; }
cl.exe
1 2 3 4 5 6 7 8 9 10
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 1.29 sec, absolute running time: 0.08 sec, absolute service time: 1.38 sec
edit mode
|
history
|
discussion