Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random number in decimal

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to generate random number between x and y which is decimal, not integer. Can you please help ?
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top