Tuesday, 20 March 2018

Generation of Random Numbers in C++

//Random Numbers
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
 clrscr();
  int n,U,i,N;
  cout<<"How many random numbers\n";
  cin>>n;
  cout<<"Upper Limit\n";
  cin>>U;
  cout<<"Random Numbers are\n";
  for(i=1;i<=n;i++)
  {
   N=rand()%U+1;
   cout<<N<<"\t";
  }
 getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.