in Programming in C
962 views
0 votes
0 votes
#include<stdio.h>

int main()

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

c==a==b;

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

return0;}
in Programming in C
962 views

3 Answers

1 vote
1 vote
Best answer
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.
selected by

2 Comments

what is the associativity of equality operator??
0
0

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

0
0
0 votes
0 votes

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

3 Comments

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

if it was c = a == b then my logic was correct
0
0
0 votes
0 votes
10 20 30
== is relational operator not the assignment operator. So value of a.b.c has not changed

Related questions