361 views
#include<stdio.h>

int main()

{ int a=10,b=20,c=30;

c==a==b;

Printf("%d%d%d",a,b,c);

return0;}
| 361 views

+1 vote
Output: 102030

Explanation: Since "==" is a relational operator and not an assignment operator, value of none is changed.

It's just evaluating whether they are equal or not without performing any assignment.

NOTE: This code isnt properly formatted so might not produce output.
by Junior (941 points)
selected by
0
what is the associativity of equality operator??
0

Shubhanshu  Both == and != have the same precedence with associativity left to right.

a == b is checked if they are equal .... they are not equal

therefore returns 0 which is assigned to c

therefore a=10 b =20 c =0

ANS - 10 20 0

by Boss (10.2k points)
0
But the output is 102030 please explain
0
Although comparison of A and B returns 0 but that in fact is not assigned to C. So C remains unchanged.
0
got it :)

if it was c = a == b then my logic was correct
10 20 30
== is relational operator not the assignment operator. So value of a.b.c has not changed
by Active (2.3k points)