Jun 14, 2001 #1 Guest_imported New member Joined Jan 1, 1970 Messages 0 I want to generate random number between x and y which is decimal, not integer. Can you please help ?
I want to generate random number between x and y which is decimal, not integer. Can you please help ?
Jun 14, 2001 #2 Zyrenthian Programmer Joined Mar 30, 2001 Messages 1,440 Location US for(int i = 0;i<10;i++) { x=(double)(rand()%100); y=(double)rand()/(double)rand(); while(y>1) { y/=10; } x+=y; cout<<x<<endl; } Random number between 0 and 99... this should help you on your way... x & y are doubles =) matt Upvote 0 Downvote
for(int i = 0;i<10;i++) { x=(double)(rand()%100); y=(double)rand()/(double)rand(); while(y>1) { y/=10; } x+=y; cout<<x<<endl; } Random number between 0 and 99... this should help you on your way... x & y are doubles =) matt