Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
PrepSter Input OutPut Questions 1
November 22, 2019
Question
What will be the output of this program ?
Option – 1. No, compile error but it’ll print Advance Four-time.
Option – 2. No, compile error but it will run into an infinite loop printing Advance.
Option – 3. No, compile error but it’ll print Advance Five-time
Option – 4. Compile-time error.
Solution
No, compile error and it’ll print Advance Five-time
Explanation
Step – 1 :
for ( ; ; )
{
if (1) //not zero
j = –i //j & i = 0
if(0<5) //true
printf(“advance”,j++); // j = 1
}
Step – 2 :
for ( ; ; )
{
if (0) // zero condition false
j = –i
if(1<5) //true
printf(“advance”,j++); // j = 2
}
Step – 3 :
for ( ; ; )
{
if (0) // zero condition false
j = –i
if(2<5) //true
printf(“advance”,j++); // j = 3
}
Step – 4 :
for ( ; ; )
{
if (0) // zero condition false
j = –i
if(3<5) //true
printf(“advance”); // j = 4
}
Step : 5
for ( ; ; )
{
if (0) // zero condition false
j = –i
if(4<5) //true
printf(“advance”,j++); // j = 5
}
Disclaimer-: The questions provided on this page are only model practice questions there is no surety that these questions have been previously asked in any company placement papers, these questions here only have the sole purpose to make you practice coding questions
Provide Solutions