Correct Answer - Option 1 : Getting out is printed infinite times
Concept:
while loop:
Statements within the while loop would keep getting executed till the condition being tested remains true. When condition becomes false, control passed to the first statement that follows body of the loop. While loop will be executed atleast 0 times.
Syntax:
Initialize loop counter;
While(condition)
{
Statement;
Increment loop counter;
}
Calculation:
main()
{
int i = 8;
while (i = 8)
{
printf ("Getting out");
i++;
}
}
- When i = 8, as the condition is satisfied, the print will display Getting out in the output.
- Now after incrementing i to 9, the while loop gets completed.
- Again i is assigned 8 and again while loop will be executed.
- So this process will keep on running infinite times, hence Getting out is printed infinite times.
Hence option(1) is the correct answer.