Home » C Programming » Operators » Question
  1. Which of the following is the correct output for the program given below?
    #include <stdio.h>
    int main ( )
    {
    int a = 25;
    printf ("%d %d %d\n",a <= 20, a = 15, a >= 10);
    return 0;
    }
    1. 1 15 1
    2. 1 20 1
    3. 1 25 0
    4. 1 1 1
    5. 0 0 0
Correct Option: A

Step 1: int a=25; here variable a is declared as an integer type and initialized to '25'.

Step 2: printf("%d, %d, %d\n", a<=25, a=20, a>=10);
In printf the execution of expressions is from Right to Left.
here a>=10 returns TRUE hence it prints '1'.
a=15 here a is assigned to 15 Hence it prints '15'.
a<=55 returns TRUE. hence it prints '1'.

Step 3: Hence the output is "1, 15, 1".



Your comments will be displayed only after manual approval.