I know how to make random numbers. and How to make random numbers in a specific range. BUT!!! How can you display 'x' random numbers in a given range and make it so the output display lists the numbers in groups a 'y'. For example: I want to display 25 random numbers between 1-100 in groups of 5 numbers per line. Of course the user could change those values. the values of 'x' and 'y' are decided by the user. any help of hints would be great.
zeus1216gw
17
Light Poster
Recommended Answers
Jump to PostYou could use 2 nested loops:
for (int x = 0; x < user_x; x++) { for (int y = 0; x < user_y; y++) { // do stuff } std::cout << '\n'; // next line }
Or you could use one loop and use the remainder …
Jump to PostI know how to make random numbers. and How to make random numbers in a specific range. BUT!!! How can you display 'x' random numbers in a given range and make it so the output display lists the numbers in groups a 'y'. For example: I want to display 25 …
Jump to PostIs there a 'z' involved, as in the total number of groups?
z can be calculated using x and y, but having an actual z makes it harder to handle an x that isn't perfectly divisible by y.
Jump to PostIf you are getting errors, then you have some code, right? Somebody can help you fix them if you show the code and say what the errors are.
Jump to Postsorry I forgot to add the groups need to be on the same line separated by a blank line
That's idiotic I think you want to say blank space.
Hey you really cant expect us to give every detail.You need to work yourself.If you need the groups to be on …
All 21 Replies
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
VernonDozier
2,218
Posting Expert
Featured Poster
Tom Gunn
1,164
Practically a Master Poster
jephthah
commented:
Bork Bork Bork
+12
zeus1216gw
17
Light Poster
Tom Gunn
1,164
Practically a Master Poster
zeus1216gw
17
Light Poster
csurfer
422
Posting Pro
zeus1216gw
17
Light Poster
wildgoose
420
Practically a Posting Shark
Tom Gunn
1,164
Practically a Master Poster
csurfer
422
Posting Pro
zeus1216gw
17
Light Poster
VernonDozier
2,218
Posting Expert
Featured Poster
wildgoose
420
Practically a Posting Shark
csurfer
422
Posting Pro
Tom Gunn
1,164
Practically a Master Poster
zeus1216gw
17
Light Poster
VernonDozier
2,218
Posting Expert
Featured Poster
zeus1216gw
17
Light Poster
zeus1216gw
17
Light Poster
csurfer
422
Posting Pro
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.