Home / C Programming / Expressions :: Discussion

Discussion :: Expressions

  1. What will be the output of the program?

    #include
     int main() 
    {   
       int a=100, b=200, c;   
       c = (a == 100 || b > 200);   
       printf("c=%d\n", c);   
       return 0; 
    }
    

  2. A.

    c=100

    B.

    c=200

    C.

    c=1

    D.

    c=300

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Step 1: int a=100, b=200, c;
    Step 2: c = (a == 100 || b > 200);
    becomes c = (100 == 100 || 200 > 200);
    becomes c = (TRUE || FALSE);
    becomes c = (TRUE);(ie. c = 1)
    Step 3: printf("c=%d\n", c); It prints the value of variable i=1
    Hence the output of the program is '1'(one).


Be The First To Comment