CIS 162 AD - C# Programming I - Section 5832
Worksheet #4
Due Thursday, March 2, 2006

Name:

I. Definitions: please explain the following terms:

  1. iteration structure

  2. infinite loop

  3. MessageBox

  4. nested loop

  5. continue statement

  6. off-by-one error

  7. scope

  8. garbage collection

II. Questions or short essay

  1. How is a pre-test loop different from a post-test loop?

  2. How is a sentinel-controlled loop different from a counter-controlled loop?

  3. Explain the syntax of the for loop.

  4. What is the purpose of the foreach statement?

  5. Why would a program use a loop?

  6. In what situation might a for loop work best?
III. Programming Exercises Write source code for the following:

    Write a program to calculate the average of all scores entered between 0 and 100. Use a sentinel-controlled loop variable to terminate the loop. After values are entered and the average calculated, test the average to determine whether an A, B, C, D, or F should be recorded. The scoring rubric is as follows:
    A: 90 to 100; B: 80 to 89; C: 70 to 79; D: 60 to 69; F: less than 60.