‹ Back to the paper
Question 15
2 marks
Computer ScienceISC 2022 Computer Science - Specimen paper (Semester 1), Paper 1MCQStatements, Scope
Choose the correct option.
What is the output of the code given below? int i, j; for(i = 1; i <= 5; i++); for(j = i + 1; j <…
What is the output of the code given below?
int i, j;
for(i = 1; i <= 5; i++);
for(j = i + 1; j < 1; j++);
System.out.print(i + "+" + j);- (a)67
- (b)1+2
- (c)6+7
- (d)12
Answer
Answer
Correct option: (c)
Answer: (c) 6+7
The first loop ends with i=6. Then j starts at 7 and j<1 is false, so j stays 7. It prints 6+7.