Monday, October 17, 2011

Linear Congruential method ( Random Number generation )





#include
#include
#include
int main()
{
int a,c,x0,m,n1,n2,true;

clrscr();
printf(" enter a, c, x0, m : ");
scanf(" %d %d %d %d", &a, &c, &x0, &m);



n1 = x0;

while(true !=1)
{


n2 = (a*n1+c) % m;

printf(" %.2f\t",(float)n1/m );

if(n2 == x0)
true = 1;

n1 = n2;


}

getch();
return 0;
}

by Amrendra Kumar mca/4549/09

No comments:

Post a Comment