Page 220 - CA_Blue( J )_Class10
P. 220
6. Write a program to print the following patterns:
a. 1 b. 12345
2 4 2345
3 6 9 345
4 8 12 16 45
5
c. 10 9 8 7 d. 1 1 1 1 1
6 5 4 2 2 2 2
3 2 3 3 3
1 2 2
1
e. 1 f. x # x # x
01 x # x #
101 x # x
0101 x #
10101 x
g. A
B C
D E F
G H I J
C. Assertion and Reasoning based questions.
The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the
appropriate option given below:
a. Both A and R are true, and R is the correct explanation of A.
b. Both A and R are true, but R is not the correct explanation of A.
c. A is true, but R is false.
d. A is false, but R is true.
1. int i = 1;
while (i <= 3)
{
for (int j = 1; j <= 4; j++)
{
System.out.println("i: " + i + ", j: " + j);
}
}
Assertion (A): The following code will result in an infinite loop.
Reason (R): The outer loop does not have an increment statement.
2. for (int i = 1; i <= 3; i++)
{
for (int j = 1; j <= 4; j++)
{
System.out.println("Nested Loop");
}
}
Assertion (A): The following code will print "Nested Loop" 12 times in same line.
Reason (R): The outer loop runs 3 times, and the inner loop runs 4 times.
218218 Touchpad Computer Applications-X

