CIS 162 AD - C# Programming I - Section 5832
Worksheet #4
Due Thursday, March 2, 2006
Name:
I. Definitions: please explain the following terms:
- iteration structure
- infinite loop
- MessageBox
- nested loop
- continue statement
- off-by-one error
- scope
- garbage collection
II. Questions or short essay
- How is a pre-test loop different from a post-test loop?
- How is a sentinel-controlled loop different from a counter-controlled loop?
- Explain the syntax of the for loop.
- What is the purpose of the foreach statement?
- Why would a program use a loop?
- 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.