Friday, September 2, 2011

PROGRAM TO GENERATE RANDOME NUMBER IN C/C++

This program can generate random number, from 0 to 6

CODING
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<iomanip.h>
main()
{
srand(time(0));
clrscr();
        for (int count=1; count<=5; count++)
            {
            int a=rand() % 6;
            cout<<setw(5)<<a<<endl;
            }
getche();
return 0;
}

No comments:

Post a Comment