0
The Output is 19 of the below code, The question is "How" ?, I really don't get it !
int a,b,c; a = 12; b = 7; c = 24; cout << c-a % b;
7 Respuestas
+ 4
The output is 19 because of the operator precedence and associativity rules of C++.
In the given code, the expression a % b is evaluated first because the modulus operator % has higher precedence than the subtraction operator -. So, a % b evaluates to 5.
Then, the expression c - 5 is evaluated, which gives the result 19. This is because subtraction has left-to-right associativity, which means that the expression will be evaluated from left to right.
Therefore, the final output is 19.
+ 3
Okay okay got it, its like DMAS system 👍🏻. Thanks for the help :)
+ 2
12 % 7 = 5
24 - 5 = 19
+ 2
You have to study operator precedence to figure out what is going on 👍
+ 1
Oky got it thanks :)
+ 1
Yeah i already got it, it is similar to the DMAS (Divide/Multiply/Addition/Subtract) of what we studied in our Mathematics 😃.
0
But it says that firstly subtract c & a and then 'remainders' their answers to the b. Am i saying right ?