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 PostSo 'x' is the number of numbers per line, 'y' is the number of lines? Is there a 'z' involved, as in the total number of groups?
xxxx xxxx xxxx xxxx xxxx xxxx
x = 4, y = 3, z = 2 above?
z can be calculated using x …
Jump to PostYou're the only one who started talking about z. The OP only wanted x and y. x is the total count of random numbers, y is the count of numbers in each group. The number of groups is calculated by x/y.
I'm defining z as the number of groups, just …
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.