3%8 = 3 . But why and how? [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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?

21st Sep 2022, 5:42 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
14 Answers
+ 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
21st Sep 2022, 6:08 PM
Suparna Das
Suparna Das - avatar
+ 12
https://www.geeksforgeeks.org/modulo-operator-in-c-cpp-with-examples/ For further details you can even visit this site
21st Sep 2022, 6:13 PM
Suparna Das
Suparna Das - avatar
+ 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
21st Sep 2022, 5:50 PM
Suparna Das
Suparna Das - avatar
+ 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
21st Sep 2022, 10:18 PM
Solo
Solo - avatar
+ 2
Suparna Das Oh Thanks got it now 👍
21st Sep 2022, 6:12 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 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"
22nd Sep 2022, 7:54 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
You can learn clearly in this video: https://youtu.be/MrTtsX2Wg9Q
22nd Sep 2022, 12:12 PM
uzHerzeg
uzHerzeg - avatar
0
Am confused
22nd Sep 2022, 11:25 PM
Dante Humble🙏daddy
Dante Humble🙏daddy - avatar
23rd Sep 2022, 5:51 AM
ALI Moussa Kadjalla
ALI Moussa Kadjalla - avatar
0
o
23rd Sep 2022, 6:30 AM
Sk Aman
Sk Aman - avatar
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
23rd Sep 2022, 8:48 AM
Devil Hacker SHREYANSH SINGH😏😏
Devil Hacker  SHREYANSH SINGH😏😏 - avatar
- 1
Suparna Das but... 0.375 ______ 8|3.000 24 _____ 60 56 _____ 40 40 _____ 0 Still this does not seem to be like that...
21st Sep 2022, 6:07 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
- 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)
22nd Sep 2022, 10:45 PM
ALI Moussa Kadjalla
ALI Moussa Kadjalla - avatar
- 1
Dis nigga wassa bitch , foo I'mma smack yo ass up nigha
23rd Sep 2022, 2:49 AM
Anthony Botlero
Anthony Botlero - avatar