I need to make a program that outputs a random number between 1 and 10 every half of a second. Right now i dont know how to generate random numbers or use a timer so i need lots of helf here.
Hockeyfreak889
0
Light Poster
Recommended Answers
Jump to Postuse srand() to seed the random number generator, rand() to get a random number, and the mod operator % to imit the number betwen 1 and 10. Get that working in your program first, then we can talk about how to make it do that every 1/2 second.
You …
Jump to Postyou need to use the Sleep() function in Windows or sleep() in *nbix. Note the capatilization of the letter S.
while(true) { // display a random number Sleep(500); }
If you don't want to use that system functin then you could probably create a loop using the …
All 7 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Hockeyfreak889
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Hockeyfreak889
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Hockeyfreak889
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.