Examveda
Examveda

Find the output of the following program.
#include<stdio.h>
void main()
{
   int y=10;
   if(y++>9 && y++!=10 && y++>11)
      printf("%d", y);
   else
      printf("%d", y);
}

A. 11

B. 12

C. 13

D. 14

E. Compilation error

Answer: Option C

Solution(By Examveda Team)

Here if Statement is true and if statement executes left to right. Since its AND operator so all the condition should be check until it finds any false statement. Initially y = 10 In 1st condition: y++>9 which is true and y become 11 in next use. In 2nd condition: y++!=10 which is also true and y become 12 in next use In 3rd condition: y++>11 which is also true and y become 13 in next use After that printf statement will execute and print y = 13

This Question Belongs to C Program >> Control Structures

Join The Discussion

Comments ( 6 )

  1. Nabin Bhandari
    Nabin Bhandari :
    7 months ago

    WHAT IS THIS PROGRAMS OUTPUT
    CLS
    W$="PATTERN"
    FOR I=1 TO 7 STEP 1
    PRINT LEFT$(W$,I)
    NEXT I;
    END

  2. Siva Sangari
    Siva Sangari :
    8 months ago

    #include
    #include
    main()
    {
    float a,s,sq;
    printf ("/n enter the number");
    scanf ("%f", &a);
    s=a8a;
    sq=srrt(a);
    printf ('/n square= %f," s);
    printf ("/n square root =%f," sq);
    }

  3. Zelko Zeed
    Zelko Zeed :
    1 year ago




    What is program output
    #include
    void main 0 {
    int i = -1, j = -1, k = 0, I = 2, m;
    m = i++ &&j++ &&k++ ll 1++;
    printf (" Vo dLo d%o dvo dLo d",i j,k,l,m) ;
    l

  4. Ujwal Channel
    Ujwal Channel :
    1 year ago

    Cls
    Input "Enter any 3 numbers ";N
    IF SGN (N)=1. THEN
    PRINT N; "is the odd number"
    ELSE
    PRINT N; "is null or zero number"
    ELSE IF
    END

  5. Anoop Sivakumar
    Anoop Sivakumar :
    6 years ago

    how?

  6. Ro Ma
    Ro Ma :
    6 years ago

    how

Related Questions on Control Structures