0
3%8 = 3 . But why and how? [SOLVED]
In all programming languages the answer of the equation 3%8 is 3. But how is it possible? According to me, the answer should have been 0 (Integer). Can someone please explain how this equation is done by the ALU of the processor?
14 Réponses
+ 9
[B.S.] BITTU This % is modulus operator
this operator outputs the remainder instead of a quotient
so when you divide
0
____
8 | 3
-0
--------
3
Just stop till here
Consider the remainder -> 3
Because an Integer won't display the decimal values
The decimal values will be displayed if you use float datatype but your question is of integer
+ 12
https://www.geeksforgeeks.org/modulo-operator-in-c-cpp-with-examples/
For further details you can even visit this site
+ 9
This 👉🏻 % is a modulus operator and is used to display the REMAINDER of the division
If we divide 8 from 3 we are getting remainder 3
here while dividing don't consider the quotient
consider the remainder
+ 5
In this case, there is no need to share anything.
If the dividend is less than the divisor, then the result will be equal to the dividend.
If 3 < 8 then 3%8 = 3;
P. S: "It is very easy to check this statement: a%b == a-a//b*b".
https://code.sololearn.com/csOtd0eWyoZi/?ref=app
+ 2
Suparna Das Oh Thanks got it now 👍
+ 1
Jeshwanth Jesh Statements are some built-in functions or better say , commands in all programming languages that take arguments and perform some specific tasks on the argument without returning a value.
Statements of any programming language can't be customized.
Example:
C : printf();
Python: print()
C++ cout
Java: System.out.println()
Functions can either be user defined or built-in that can perform more complex instruction sets and functions, unlike statements, can be customized which might return a valid value. Function has a similarity to a statement that is , functions too can take arguments.
Example:
C/++ void myFunction()
Python: def myFunction()
Java: static void myFunction()
Sidenote:
Functions is java are actually called "Methods"
+ 1
You can learn clearly in this video:
https://youtu.be/MrTtsX2Wg9Q
0
Am confused
0
0
o
0
the operation modulo(%) finds the rest or the rest signed after the division of a number by another (called the module of the operation).
Given two positive numbers, a and n, a modulo n (a%n, abbreviated as a mod n) is the rest of the Euclidian division of a by n, where a is dividend and n is divider.
This operation can satisfy also the following formula a*(a//b)+(a%b) for example 3*(3//8)+(3%8) like that
- 1
Suparna Das but...
0.375
______
8|3.000
24
_____
60
56
_____
40
40
_____
0
Still this does not seem to be like that...
- 1
the operation modulo(%) finds the rest or the rest signed after the division of a number by another (called the module of the operation).
Given two positive numbers, a and n, a modulo n (a%n, abbreviated as a mod n) is the rest of the Euclidian division of a by n, where a is dividend and n is divider.
This operation can satisfy also the following formula a*(a//b)+(a%b) for example 3*(3//8)+(3%8)
- 1
Dis nigga wassa bitch , foo I'mma smack yo ass up nigha