Page 202 - CA_Blue( J )_Class10
P. 202
i n j f=f*i Output (Factorial of n)
1 3 1 1x1 1
2 1x2 2
3 2x3 6
2 4 1 1x1 1
2 1x2 2
3 2x3 6
4 6x4 24
9.3 NESTED DO-WHILE LOOP
If a do-while loop is used within another do-while loop, then it is called a nested do-while loop. Let us take an example.
Write a program to input 2 number and print the Armstrong numbers. An Armstrong number of 3
Program 3
digit is a number that is equal to the sum of the cube of the digits.
1 import java.util.*;
2 class nested_dowhile
3 { public static void main()
4 { int i,n,s,t,r;
5 Scanner sc= new Scanner(System.in);
6 i=1;
7 do
8 { System.out.print("Enter a number : ");
9 n=sc.nextInt();
10 t=n; s=0;
11 do
12 { r = t%10;
13 s = s + (r*r*r);
14 t=t/10;
15 } while(t>0);
16 if(s==n)
17 System.out.println(n + " is Armstrong Number ");
18 else
19 System.out.println(n + " is not Armstrong Number ");
20 i++;
21 }while(i<=2);
22 }
23 }
200200 Touchpad Computer Applications-X

