Random number generator in C++ with source code

Random number generator in C++ with source code


Random number generator is a mini project in c plus plus(C++). It is a C++ programming-based project.

Random number project is coded in C++ programming. This project is good for learning and understanding c programming. The program is useful for generating random integer between zero and number entered. When you compile and execute the program it will asks you to enter a max number.

And the program will generate the random number between zero and entered number. According to the code, it will ask you to enter number for 10 times. You can decrease this time. It has command-line interface and is very easy to use and implement. It is a very useful project.

See the source code below:

#include <iostream>
#include <ctime> 
#include <cstdlib>
using namespace std;

int main()
 int max, random_num, i;
 cout << "Please input max number: ";
 cin >> max;

 random_num = (rand () % max) + 1;

 cout << random_num << endl;


random number

How to use this random number project?

  • Download the software Dev C++ or any other. 
  • Copy and paste the code above. 
  • Compile and execute the code.
  • Generate the random integer.
  • Enjoy and share.

Spread the love