Nested Loops: ============= Syntax: for(initialization; condition; update) { loop body statements; for(initialization; condition; update) { loop body statements; } } for(initialization; condition; update) { loop body statements; initialization for while; while(condition) { while loop body; update; } } initialization for while; while(condition) { while loop body; for(init; condition; update) { for loop body; } update; } // nested loops // 4 X 7 pattern // with numbers class nestedLoops{ public static void main(String x[]) { //row implementation for(int row = 1;row <= 4;row++) { for(int col = 1;col <= 7;++col) { System.out.print(col+"\t"); } System.out.println(); } } } ================================================== // WAP TO PRINT ALL THREE PALINDROME NUMBERS. // we should iterate from 100 to 999 // while iterating, that every number can be apply for checking whether it is palindrome number or not. class palindromePrint{ public static void main(String x[]) { int i = 100; while(i <= 999) { int j = i; int reverse = 0,remainder; for(;j != 0;) { remainder = j % 10; reverse = reverse * 10 + remainder; j/=10; } if(reverse == i) { System.out.print(i+"\t"); } ++i; } System.out.println(); } } ================================================= Q: WAP TO PRINT ALL 7 MULTIPLES FROM 1000 TO 2000. ============================ // WAP TO CHECK WHETHER THE NUMBER IS ARMSTRONG NUMBER OR NOT. // THE SUM OF EQUIALENT POWERS OF INDIVIDUAL DIGITS OF A NUMBER IS EQUALS TO GIVEN NUMBER IS CALLED AS "ARMSTRONG NUMBER" // XYZ => X^3 + Y^3 + Z^3 == XYZ // abcd => a^4 + b^4 + c^ 4 + d^4 == abcd // pow(x,y) ==> x^y //math.pow(x,y) import java.util.Scanner; class CheckingArmstrong{ public static void main(String x[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a three digit value;"); int num = sc.nextInt(); int ind_dig,powers,s_power = 0; for(int n = num;n != 0;) { ind_dig = n % 10; powers = ind_dig * ind_dig * ind_dig; s_power = s_power + powers; n /= 10; } if(s_power == num) { System.out.println("It is an Armstrong number."); } else { System.out.println("It is not an Armstrong number."); } } }