Skip to content
Programmingoneonone
Programmingoneonone
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

C++ game to find out number

YASH PAL, 31 July 202427 January 2026

In this post, we will write a C++ program to find out the random number generated by the computer. you can run this game’s source code into turbo c++ or in any other code editor.

C++ game to find out the random number generated by the computer

C++ game to find out random numbers.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

void main()
{
    clrscr();

    int n,k,c=0;

    k = rand()%100;

    cout<<"Computer has selected a number b/w 0-100 and save it in its memory"<<endl;

    in:
    cout<<"Enter the number to find out the hidden number = ";
    cin>>n;
    c++;

    if(n>k)
        cout<<"Your number greater"<<endl;
    if(n<k)
        cout<<"YOur number is smaller"<<endl;

    if(n==k)
    {
        clrscr();
        cout<<endl;
        cout<<"The number is found"<<endl;
        cout<<"The number is "<<k<<endl;
        cout<<"You find out the number after mistakes = "<<c<<endl;

        getch();

        exit(0);
    }
    goto in;
}

Output

Computer has selected a number b/w 0 - 100 and save it in its memory
Enter the number to find out the hidden number = 50
Your number is smaller
Enter the number to find out the hidden number = 60
Your number is smaller
Enter the number to find out the hidden number = 70
Your number is smaller
Enter the number to find out the hidden number = 80
Your number is smaller
Enter the number to find out the hidden number = 75
Your number is smaller
Enter the number to find out the hidden number = 78
Your number is smaller
Enter the number to find out the hidden number = 79

The number is found
The number is 79
You find out the number after mistakes = ?
C++ Programming Tutorials coding problems solutions Programs

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

CLOSE ADS
CLOSE ADS

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes