Advertisement
Guest User

IT 10 REVIEWER ANSWERS - LOOPS

a guest
Feb 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. 1. Write the syntax of the following loops:
  2. a. While Loop
  3. ==========
  4. While i < 100
  5. Console.WriteLine(i)
  6. i += 10
  7. End While
  8. ==========
  9.  
  10. b. Do Loop ( all 4)
  11. ========== DO LOOP WHILE
  12. Do // DO LOOP WHILE executes the code first before checking the condition and stops
  13. [ statements ] // if it's satisfied.
  14. Loop While [condition] // Minimum # of executions (if condition is not satisfied): 1
  15. ==========
  16.  
  17. ========== DO LOOP UNTIL
  18. Do // DO LOOP UNTIL executes the code first before checking the condition and stops
  19. [ statements ] // if it's satisfied.
  20. Loop Until [condition] // Minimum # of executions (if condition is not satisfied): 1
  21. ==========
  22.  
  23. ========== DO WHILE LOOP
  24. Do While [condition] // DO UNTIL LOOP checks the condition first then executes the code and stops if it's
  25. [ statements ] // satisfied.
  26. Loop // Minimum # of executions (if condition is not satisfied): 0
  27. ==========
  28.  
  29. ========== DO UNTIL LOOP
  30. Do Until [condition] // DO UNTIL LOOP checks the condition first then executes the code and stops if it's
  31. [ statements ] // satisfied.
  32. Loop // Minimum # of executions (if condition is not satisfied): 0
  33. ==========
  34.  
  35. c. For Loop
  36. ==========
  37. For value As Integer = 0 To 5 // FOR Loop will continue to automatically increment "value" and stops once reaches 5
  38. [statements]
  39. Next
  40. ==========
  41.  
  42. 2. When will each loop statement execute (before or after the
  43. condition is tested)?
  44. a. While Loop
  45. > after the condition is tested.
  46. b. Do While Loop
  47. > after the condition is tested.
  48. c. Do Loop While
  49. > before the condition is tested.
  50. d. Do Until Loop
  51. > after the condition is tested.
  52. e. Do Loop Until
  53. > before the condition is tested
  54. f. For Loop
  55. > after the condition is tested.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement