What is the output of the below given code?
int m = 23;
m = m% (m * 3);
printf("%d",m);
% → modulus operator
printf() function
The printf() function is used for output. It prints the given statement to the console.
Analysis:-
m = m%(m*3)
Calculation:
m = 23 mod (23 × 3)
m = 23 mod 69
m = 23
Note:
Assignment operator associativity is right to left.
Printf statement will print the value of m as 23. (Output would be 23).
Confusion PointsHere 23 mod 69 means. 23 is divided by 69. That's why 23 is the answer. For better clarity, you can run the above program and check.
Additional Information
|
Operator |
Description |
Associativity |
|
( ) [ ] . → ++ -- |
Parentheses or function call Brackets or array subscript Dot or Member selection operator Arrow operator Postfix increment/ decrement |
Left to right |
|
++ -- + - ! ~ (type) * & sizeof |
Prefix increment/ decrement Unary plus and minus Not operator and bitwise complement Type cast Indirection or dereference operator Address of operator Determine size in bytes |
Right to left |
|
*/% |
Multiplication, division and modulus |
Left to right |
|
+ - |
Addition and subtraction |
Left to right |
|
≪ ≫ |
Bitwise left shift and right shift |
Left to right |
|
< <= > >= |
Relational less than/less then equal to Relational greater than/greater than or equal to |
Left to right |
|
== != |
Relational equal to or not equal to |
Left to right |
|
&& |
Bitwise AND |
Left to right |
|
^ |
Bitwise exclusive OR |
Left to right |
|
I |
Bitwise inclusive OR |
Left to right |
|
&& |
Logical AND |
Left to right |
|
I I |
Logical OR |
Left to Right |
|
? : |
Ternary operator |
Left to right |
|
= += -= *= /= %= &= ^= I= |
Assignment operator Additional/subtraction assignment Multiplication/division assignment Modulus and bitwise assignment Bitwise exclusive/inclusive OR assignment |
Right to left |
|
, |
Comma operator |
Left to right |
