Doyle: C#, 5th edition Page 1-1
1. b. 1000
2. c. to allow statements to be repeated
7. b. while (counter < 10)
8. b. for (num = 0; num < 10; num++)
9. d. 2
14. d. curly braces
15. d. five times
C# Programming: From Problem Analysis to Program Design, 5th edition
Chapter 6
Doyle: C#, 5th edition Page 1-2
18. a. 20
21. for (int counter = 100; counter > 0; counter)
{
}
Final result is the same for all three loop constructs. Both the for statement
and the while statement are tested before entry into the loop.
Doyle: C#, 5th edition Page 1-3
}
23. int temp = 0;
int totalTemp = 0;
Console.WriteLine(“To stop entering values, type 99”);
inValue = Console.ReadLine( );
temp = int.Parse(inValue);
while (temp != -99)
{
Doyle: C#, 5th edition Page 1-4
}
24. Random rNum = new Random( );
int randomValue,
{
sumOfRandomValues += randomValue;
totalRandomValues++;
randomValue = rNum.Next(25, 76);
}
Doyle: C#, 5th edition Page 1-5
25.
i j Output area:
0 4 0 4
1 4 1 4
1 3 1 3
1 2 1 2
1 1 1 1
3