0

Random Number

Posted March 24th, 2010 in Programming Corner and tagged , by Paran

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int x0,k,a,m,i,j,random[20],r;
cout<<”Enter your x0 value = “;
cin>>x0;
cout<<endl<<”Enter your K value: = “;
cin>>k;
cout<<endl<<”Enter the value of r>2: = “;
cin>>r;
m=pow(2,r);
a=k*8+3;
for(i=0;i<10;i++)
{
random[i]=(x0*a)%m;
x0=random[i];
}
cout<<”Random numbers are:”<<endl;
for(j=0;j<i;j++)
cout<<random[j]<<endl;
getch();
}

VN:F [1.9.10_1130]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.10_1130]
Rating: +1 (from 1 vote)
Share and Enjoy:
  • Facebook
  • Twitter
  • Google Bookmarks
  • Print
  • Live
  • Digg
  • Sphinn
  • Mixx
  • Add to favorites

Leave a Reply





  • Page 1 of 1
  • « Previous
  • 1
  • Next »