C++ Guess the Number
A fun Guess the Number Game using C++
* Featured Code Example Created and submitted by Zayn Meissner via Sololearn.
C++
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0));
int a;
int b;
a=(rand()%100);
cin >> b;
if (b==a)
{
cout << "WINNER!" << endl;
cout << "the answer : "<< a << endl;
cout << "your guess : "<< b;
}
else
{
cout << "Game Over" << endl;
cout << "the answer : "<< a << endl;
cout << "your guess : "<< b;
}
return 0;
}
Comments
Post a Comment