Home » C Programming » Decision Making » Question
  1. Which of the following is the correct output for the program given below ?
    #include  <studio.h>
    int main ( )
    {
    char ch;
    if ((ch = printf ("")));
    printf ("I am inside if \n");
    else
    printf ("I am inside else\n");

    return 0;
    }
    1. I am inside if
    2. I am inside else
    3. random value
    4. No Output
Correct Option: B

printf("")

returns the number of characters successfully printed. So the condition

if(ch = printf(""))

fails as ch is set to 0. Hence, the else clause is getting executed.



Your comments will be displayed only after manual approval.