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 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 = ?