Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • 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

C++ game to find out number

YASH PAL, 31 July 202422 August 2024

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

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes