Page 297 - CA_Blue( J )_Class9
P. 297
19 System.out.println(n+" is Automorphic Number");
20 else
21 System.out.println(n+" is not Automorphic Number");
22 }
23 }
You will get the following output:
Enter a number : 25
25 is Automorphic Number
Enter a number : 35
35 is not Automorphic Number
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
n int Accept a number
rem int Remainder
sq int Square of the number
temp int Temporary Variable
count int Counter Variable
(ix) Programs based on nested loops.
Write a program to print the following structure:
Program 19
1
2 3
4 5 6
.
.
nth line
1 import java.util.*; //importing “util” package
2 class pattern1 // class name
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 int i,j,n,k=1; //Declaration of variable
8 System.out.print("Enter number of lines : ");
9 n=sc.nextInt();
10 for(i=1;i<=n;i++) //Loop variable for number of lines
11 {
12 for(j=1;j<=i;j++) //Loop variable for number of columns
Internal Assessment 295

