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;
}

Click here to see this code and play



More Free Code Examples:


C++ Odd or Even


Javascript Easy Battleship Game






Comments

Popular posts from this blog

Crypto Mining

Multi-tap Keypad Text Entry