Technical Aptitude :: Control Instructions - Discussion
Home > Technical Aptitude > Control Instructions > MCQs Questions Discussion
80 / 33
Choose the correct option.
Vijay wants to print the following pattern on the screen: 1
1 2
1 2 3
He writes the following program:
integer i = 1 // statement 1
while ( i <= 3 )
{
int j // Statement 2
while ( j <= i ) // Statement 3
{
print j
print blank space
j = j + 1 // Statement 4
}
print end-of-line \takes the cursor to the next line i = i + 1
}
Will this program function correctly? If not which one statement will you modify to make the program function correctly?
AStatement 1
BStatement 2
CStatement 3
DStatement 4
EProgram does not have error.
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
Since the value of j is not initialized, so it will store garbage value....so we need to assign j=1 for the program to run correctly.
Read Full Answer
Report Error
Please Login First Click Here