recategorized by
3,820 views
0 votes
0 votes

The value of the following expression $(13 / 4 * 3) % 5 + 1$ is

  1. $5.75$
  2. $2.95$
  3. $1.4875$
  4. $5$
recategorized by

2 Answers

0 votes
0 votes

D.

The value of the following expression (13 / 4 * 3) % 5 + 1 is

According to the precedence of the different binary operators in C,

* / and % has higher precedence than of + and -

The expression enclosed in parenthesis is executed first (13 / 4 * 3)

Since all these operators precedence is the same, they would execute from left to right
13 / 4 = 3
3.25 * 3 = 9
9.75 % 5 = 4 (Modulus operator)
4 + 1= 5

0 votes
0 votes
In C programming context $/,*.\%$ operator having equal precedence and having left to right associativity whereas $+$ sign has less priority than $/,*,\%$ & having left to right associativity.

now according to given expression $(13/4*3)\%5+1$ can be solve in following way:

$((((13/4)*3)\%5)+1)$

$((3*3)\%5)+1)$

$((9\%5)+1)$

$(4+1)$

$5$

Option $(D)$ is correct.
edited by

Related questions

1 votes
1 votes
2 answers
1
makhdoom ghaya asked Sep 5, 2016
1,771 views
Which one of the following will set the value of $y$ to $5$ if $x$ has the value $3$, but not otherwise ?If $(x = 3) y = 5$ If $x = = 3 (y = 5)$If $(x = = 3); y = 5$ If $...
1 votes
1 votes
1 answer
2
makhdoom ghaya asked Sep 5, 2016
1,865 views
How many of the following declarations are correct ?int $z = 7.0$;double void = $0.000$;short array $ = {0, 1, 2}$; char c = “\n”;NoneOne is correctTwo are correctAl...
0 votes
0 votes
1 answer
3
3 votes
3 votes
1 answer
4
makhdoom ghaya asked Sep 11, 2016
2,132 views
One of the distinguished features of super-computer over other category of computer isParallel processingHighest accuracy levelMore speedMore capacity