edited by
1,432 views

5 Answers

Best answer
4 votes
4 votes

In C Programming $*,/$ have equal precedence, and associativity is left to right.  The minus (-) operator has lower precedence than $*, /$ operator, and associativity is left to right.

Note: we use associativity rule when more than 2 operator having same precedence.

Also, in C language the result of applying a binary operator on integer types (both operands being integers) is ALWAYS INT irrespective of the operation. i.e, $5/2 = 2$ and not $2.5$ as one would normally expect.

$(((2*3)/4)-((3/4)*2))$

$((6/4)-((3/4)*2))$

$(1-((3/4)*2))$

$(1-(0*2))$

$(1-0)$

$1$

Option $B$ is correct.

Operator Precedence and Associativity in C

selected by
0 votes
0 votes
infix-> postfix evaluation

2*3/423/4* 2

=6/423/4* 2

=0/4*2

=0*2

=0 (OPTION A)
0 votes
0 votes

/ and * has equal priority and associativity is left to right

2*3/423/4*2

6/423/4*2

0/4*2

0*2

0

So answer is A)

here is code if you want to run

#include <stdio.h>
int main()
{
    int c=2*3/423/4*2;
    printf("%d",c);
    return 0;
}

Related questions

0 votes
0 votes
2 answers
1
0 votes
0 votes
1 answer
2
1 votes
1 votes
2 answers
3