The Gateway to Computer Science Excellence
0 votes
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;}
in Programming by (39 points) | 361 views

3 Answers

+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.
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.

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

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
0 votes
10 20 30
== is relational operator not the assignment operator. So value of a.b.c has not changed
by Active (2.3k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,390 answers
198,589 comments
105,443 users