View the step-by-step solution to:

These are called "nested loops".

Embedded Loops

The objective of this assignment is to give the student

more practice in using loops, especially

embedding one loop inside the other. These are called "nested loops". The assignment also

provides the opportunity to work more

with random number generators.

The assignment is

composed of two parts

, but only

for the benefit of student comprehension.


only one program that does both parts a) and b) should be turned in by the student.

The two parts are:


Write a program

in C that

determines how many calls to a random number generator it

takes to match a number between 0 and 99 that is entered by a


Use a seeded


number generation function

; otherwise all iterations of the outer loop

(part b below)

will be

the same



Embed the above program in a second loop that makes this computation 50 times and

prints out the average number of times that

the program took to find a match



number entered.

The output should be as follows:

The program took an average of <avg> random number generations to

match the target number

over the 50 experiments.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question