1. |
Answer: |

2. |
Answer: |

3. |
Re-write the preceding while loop so that it will terminate for any integer input. Answer: |

4. |
Answer: |

5. |
Write the same program with a single loop for (i = -5 ; i <= 5 ; i++) and an if in the body of the loop. Answer: |

6. |
Answer: |

7. |
Is this an improvement? Why or why not? Answer: |

8. |
Convert the while loop to a for loop. Answer: |

9. |
Is this an improvement? Why or why not? Answer: |

10. |
Convert to a while loop: Answer: |

11. |
Is this an improvement? Why or why not? Answer: |

12. |
Answer: |

13. |
You can access through the individual Answer: |

14. |
Answer: |

15. |
Leave the loop as it is and change only the expression inside System.out.print so that the program will display "1 2 3 4 5 ". Answer: |

16. |
What is the output of the following loop? Answer: |

17. |
Leave the loop as it is and change only the expression inside System.out.print so that the program will display "1 2 3 4 5 ". Answer: |

18. |
What is the output of the following loop? Answer: |

19. |
Leave the loop as it is and change only the expression inside System.out.print so that the program will display "1 2 3 4 5 ". Answer: |

20. |
Answer: |