0
What is the proper way or step by step solution for int x = (5+3*5)%3+3*7; sorry getting confused, even though i know the answer
please no negative comments thanks :) what is your answer ( why and how)
6 Antworten
+ 6
x = (5+3*5)%3+3*7
Step 1: Bracket Open
x = 5+3*5
= 5 + 15 (First Product then sum)
= 20
Step 2:
x = 20 % 3 (Remainder)
= 2
Step 3:
x = 2 + 3*7 (First Product then sum)
= 2 + 21
= 23
Answer is 23
+ 1
It is solved according to precedence order
(5+3*5)
3*5=15(*=1st precedence)
5+15=20(+=2nd precedence)
20%3(here % and * has same precedence but it has to be from left to right) so
20%3=2
2+3*7(* has higher precedence so multiplication has to be done)
2+21
answer==23
0
so what is your answer?
0
isn't 15%3 = 0 becoz there is no remainder in 15%3
and also i tried using int x=(5+3*5) % 3+3*7; in a compiler and the answer is 23 by the way already tried many steps to get 23 that's why im getting confused. ps: also tried it in w3school compiler and the answer is also 23.
0
thanks man hahaha
0
15+5=20
20%3=2