Program for auto number generator | Auto digit creator program | C++ program

Number can be generate by using 'rand' function.

We can generate number random and automatically by this method.  


These are followings things include in the program:
  1. # include <time.h>            : This is the library file which is used to generate number.
  2. srand (time(NULL));        : This is the pre-define function for change the random number. If it is not include then only one number can be display.
  3. int n=rand()%20;              : This is actual function for generate number, % 20 is the rang from which program can generate number (such as number can choose from 0 to 20)
  4. n                                          : at the end we can print value of n



 Program start here:

# include <iostream>
# include <time.h> // this library is used for do this random number generator
using namespace std;

void main ()
{
       //program for auto generated numbers

       srand (time(NULL)); //this  function must write before the 'rand' function

       int n=rand()%20; // here 20 is the rang from which the program choose random number

       cout<<"Random number are: "<<n<<endl;


}

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System