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)
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
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
- In 1951, Robert Peterson launched a chain of drive-through restaurants located primarily in California, Texas, and Arizona. From the beginning, Jack-in-the-Box
- Please refer to the attachment to answer this question. This question was created from Chap015.
- A 42 year old woman presents with nausea, anorexia and weakness 3 days after running a marathon. She has run marathons for many years. She usually recovers