Thursday, 20 March 2014

PROGRAM IN C++ TO SHOW THE USE OF RANDOMIZE FUNCTION USING HEADER FILE

//generating random numbers within range….
#include<stdlib.h>                                               //for random() or randomize() functions…
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
/*..Main Function Start’s….*/
void main()
{
randomize();
int num,rndnum;
clrscr();
cout<<ENTER THE NUMBER WHICH YOU WANT TO RANDOMIZE::::<<endl;
cin>>num;
rndnum=random(num)+7;                      /*random(num) will generates the numbers within range 0 to num-1*/
for(int n=1;n<=rndnum;n++)
cout<<n<<” “<<endl;
getch();
/*…Main Function End’s….*/
}
THE OUTPUT IS::::::::::::
Image

No comments:

Post a Comment