Home / C Programming / Control Instructions :: Discussion

Discussion :: Control Instructions

  1. Point out the error, if any in the program.

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

  2. A.

    100

    B.

    200

    C.

    Error: L value required for b

    D.

    Garbage value

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Variable b is not assigned.

    It should be like:

    b = a >= 5 ? 100 : 200;


Be The First To Comment