Day4_ControlStatements DAY4: ------ 1.if/else if 2.Loopings(for,while,do-while) 3.Switch case 4.break/continue QUESTIONS(Theory) ------------------ 1.What is difference between break and continue? 2.Whether we can use continue statement in switch? 3.What is mean by control statments and types? 4.What is mean by for loop? 5.Can you explain about for loop execution process? 6.What is difference between while and do-while? 7.What is the use of default keyword in switch? 8.Difference between for and while loop? QUESTIONS(Find the output) ----------------------- QUESTION 1: ------------ package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 100; i++) { if (i == 5) { } System.out.println(i); } } } QUESTION 2: ------------ package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 10; i++) { if (i == 5) { break; } System.out.println(i); } } } QUESTION 3: ---------- package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 10; i++) { if (i == 5) { continue; } System.out.println(i); } } } QUESTION 4: ------------ package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { System.out.println(j); } } } } QUESTION 5: ------------ package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { System.out.println(i); } } } } QUESTION 6: ----------- package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= i; j++) { System.out.println(j); } } } } QUESTION 7: ----------- package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 3; i++) { for (int j = i + 1; j <= 3; j++) { System.out.println(j); } } } } QUESTION 8: ------------ package org.test; public class Hello { public static void main(String[] args) { for (int i = 1; i <= 3; i++) { for (int j = i + 1; j <= i; j++) { System.out.println(j); } } } } QUESTION 9: ------------ package org.test; public class Hello { public static void main(String[] args) { int i=5; if (i == 5) { break; } System.out.println(i); } } QUESTION 10: ------------ package org.test; public class Hello { public static void main(String[] args) { int i=5; if (i == 5) { continue; } System.out.println(i); } } QUESTIONS(Programs) ------------------- QUESTION 1: ----------- Description: Write Java program to allow the user to input his/her age. Then the program will show if the person is eligible to vote. A person who is eligible to vote must be older than or equal 1 to 18 years old. Example: -------- Input = 10 Output = print not eligible. QUESTION 2: ----------- Description: Write a program to find even or odd number Example: --------- Input = 10 Output = Even QUESTION 3: ------------ Description: Write a program to print even number from 1 to 100 Example: --------- Output = 2,4,....100 QUESTION 4: ------------ Description: Find the sum of odd number 1 to 100 Example: -------- Output = 2500 QUESTION 5: ----------- Description: Count of even number 1 to 100 Example: -------- Output = 50 QUESTION 6: ----------- Description: Write a program to find the factorial of a number. Example: -------- Input = 5 Output = 120 QUESTION 7: ------------ Description: Write a program to print the fibonacci series of a number 1 to 100. Example: -------- Output = 0,1,1,2,3,5..... QUESTION 8: ----------- Description: Find prime number or not. Example: -------- Input = 11 Output = prime number QUESTION 9: ----------- Description : Print the below patterns using for loop. Output: ------- 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 ----------------------- * * * * * * * * * * * * * * * -------------------------- * * * * * * * * * * * * * * * ----------------------------- QUESTION 10: ------------- Description: Find Amstrong number or not Example: -------- Input = 153 Output = Amstrong number QUESTION 11: ------------- Description: Reverse the number Example: -------- Input = 123 Output = 321 QUESTION 12: ------------- Description: Count of the number Example: -------- Input = 123 Output = 3 QUESTION 13: ------------- Description: Sum of the number Example: -------- Input = 123 Output = 6 QUESTION 14: -------------- Description: Verify the number is palindrome number not Example: -------- Input = 141 Output = Palindrome