Successfully reported this slideshow.
Your SlideShare is downloading. ×

Day 5.pptx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 15 Ad

More Related Content

Recently uploaded (20)

Advertisement

Day 5.pptx

  1. 1. Switch/While/Do while/Debug Narayan Niroula 1
  2. 2. 2
  3. 3. A switch statement starts with an expression whose type isan int, short, char, byte (or their wrapper type), String, or an enum . Local variable 3
  4. 4. Switch inside Switch 4
  5. 5. Example with boolean 5
  6. 6. While Loop While Condi tion Body code Update counter False True Exit 6
  7. 7. While Loop While Condi tion Body code Update counter False True Exit int a = 10; while(a<=15) { System.out.println(a); //a++; what happens ? } 7
  8. 8. Do …while Do body code Cond ition Exit False True int a = 10; do { //int a = 10; //what happens if you here? System.out.println("Inside do loop body"); a--; }while(a>1); 8
  9. 9. Entry level loop Exit level loop Entry level loop is a loop in which the test condition is checked first, and then loop body will be executed Exit level loop is loop in which the loop body is executed and then the given condition is checked afterward If the test condition is false , loop body will be executed If the test condition is false, the loop body will be executed at least once For loop and while loop are of this type Do—while is of this type use it where you have to check the condition is mandatory Use it where check condition is mandatory after execution 9
  10. 10. Working on rows and column 10
  11. 11. Debug 1 11
  12. 12. Debug 2 12
  13. 13. Debug3 int num1, num2,; num1 = 30; num2 = 50; System.out.println("Before swapping : num1, num2 = "+num1+", "+ + num2); temp = num1; num1 = num2; num2 = temp; System.out.println("After swapping : num1, num2 = "+num1+", "+ + num2); } 13
  14. 14. Debug 4 What is the output? 14
  15. 15. Continue and break 15

×