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;} Programming in C programming-in-c + – S .shubham asked Oct 4, 2017 S .shubham 948 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes 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. AskHerOut answered Oct 4, 2017 selected Oct 5, 2017 by srestha AskHerOut comment Share Follow See all 2 Comments See all 2 2 Comments reply Shubhanshu commented Oct 4, 2017 reply Follow Share what is the associativity of equality operator?? 0 votes 0 votes saxena0612 commented Oct 5, 2017 reply Follow Share @ Shubhanshu Both == and != have the same precedence with associativity left to right. 0 votes 0 votes Please log in or register to add a comment.
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 A_i_$_h answered Oct 4, 2017 A_i_$_h comment Share Follow See all 3 Comments See all 3 3 Comments reply S .shubham commented Oct 4, 2017 reply Follow Share But the output is 102030 please explain 0 votes 0 votes AskHerOut commented Oct 5, 2017 reply Follow Share Although comparison of A and B returns 0 but that in fact is not assigned to C. So C remains unchanged. 0 votes 0 votes A_i_$_h commented Oct 5, 2017 reply Follow Share got it :) if it was c = a == b then my logic was correct 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes 10 20 30 == is relational operator not the assignment operator. So value of a.b.c has not changed Priyanka Agarwal answered Oct 5, 2017 Priyanka Agarwal comment Share Follow See all 0 reply Please log in or register to add a comment.