For each of the following situations, tell which type loop (while, do-while, or for) would be best in that situation:
a) Reading a list of an unknown number of homework grades for a single student.
b) Summing a series such as 1 +1/2 +1/(2 2 ) + 1/(2 3 ) + … + 1/(2 8 )
c) Testing a newly coded library function to see how it performs for different values
of its arguments.
d) Reading in the number of days of vacation taken by an employee.
a) A while loop because the list of grades may be empty.
b) A for loop, because the length of the list of numbers is known.
c) A do-while loop could be used since there will be at least one value tested.
d) A while loop because the list of grades may be empty.
You might also like to view...
A ________ is processed in a manner similar to customers standing in a grocery check-out line: The first customer in line is the first served.
A) stack B) vector C) queue D) All of the above E) None of the above
The most widely deployed protocol for large-scale virtualization environments is __________.
Fill in the blank(s) with the appropriate word(s).
Word shades selected fields ____ on the screen.
A. blue B. gray C. green D. tan
A security association is uniquely identified by three parameters: security parameter index, protocol identifier, and ________________.
Fill in the blank(s) with the appropriate word(s).