Homework 3 COP 3223C Embedded Loops

$30.00

Category:

Description

5/5 - (4 votes)

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 with random number generators.
The assignment is composed of two parts for the benefit of student comprehension. However,
the program submitted by the student should be the second one ‐ and only the second one!
The two parts are:
a) 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 user. Use a seeded random
number generation function; otherwise all iterations of the outer loop will be the same.
b) Now embed the above program in a second loop that makes this computation 50 times and
prints out the average number of times the above program took to match the number
entered.
Musts:
1) You must use at least two nested (embedded) loops.
2) You must use a seeded random number generator.
3) The output average of times the inner loop ran must be a floating point number.
4) Lastly (and obviously!), your program must be written in C and must compile and execute
correctly from Code::Blocks
Submission instructions:
Same as for HW #1 and #2: Submit your program source code as a .c file through the
Webcourses homework submission page. Please name the file as HW3 ‐ . Please put your full name as the first comment line at the top of the source code.