+ 11

What does "%" mean in programming?

I'm facing a great problem with just a tiny symbol "%". The problem is : x = numbers y = numbers puts/print x%y What sould be the output? For example : x = 9 y = 7 puts x%y What is the calculation actually? Thanks !

22nd Dec 2018, 7:22 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
23 odpowiedzi
+ 12
'%' this sign stands for modulo sign. It is use to get carry after devision. Like if you are dividing 10 by 3 then carry will be 1 because 3*3 = 9 and 1 will be carry. So x = 9 Y = 7 puts x%y will be 2 because 7*1 = 7 and you need 2 more to get 9. BTW please use search feature before posting a question. This question is been asked a lot of times.
22nd Dec 2018, 7:29 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 9
Hi Arb Rahim Badsa, We called a modulo (percent symbol "%").
22nd Dec 2018, 10:03 AM
program
program - avatar
+ 7
Was just trying to be helpful. Take it or leave it. It's no skin off my nose.
22nd Dec 2018, 7:50 AM
Charlie Mitchell
Charlie Mitchell - avatar
+ 6
Arb Rahim Badsa use this code. Try it for yourself. Change the numbers around and experiment. Have fun! https://code.sololearn.com/ctSjeIXehrNz/?ref=app
22nd Dec 2018, 7:39 AM
Charlie Mitchell
Charlie Mitchell - avatar
+ 5
Well...as long as you got the information.
22nd Dec 2018, 7:44 AM
Charlie Mitchell
Charlie Mitchell - avatar
+ 4
Yes its true for every number
22nd Dec 2018, 7:31 AM
MsJ
MsJ - avatar
+ 3
% its gives remainder after doing division operation 9%7 = 2 because 2 remains after divide 9 with 7
22nd Dec 2018, 7:26 AM
MsJ
MsJ - avatar
+ 3
I know that already Charlie Mitchell look my first comment its gives remainder by any number if 2 % 7 too then too remainder will be 2 because there is no division operation is perform i just gave an example which author of the post included
22nd Dec 2018, 7:47 AM
MsJ
MsJ - avatar
+ 3
One thing to add: In Python you can (same logic) also use modulo with floats: 3.6 % 1.1 == 0.3 (Well - about 0.3 ^^)
22nd Dec 2018, 9:11 AM
HonFu
HonFu - avatar
+ 3
Thank you very much for the great contribution ! It was very very helpful ! Thanks everyone !
22nd Dec 2018, 5:38 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Its called the modulo operator..using basic elementqry school division..it means you can only subtract a 7 from 9,with a remainder of 2
23rd Dec 2018, 3:42 AM
Codebeast**
Codebeast** - avatar
+ 2
this can help u https://cs50.stackexchange.com/questions/ 9072/modulo-not-working-in-greedy
22nd Dec 2018, 7:35 AM
MsJ
MsJ - avatar
+ 2
its called modulus and its used to get the reminder of two numbers eg:- if 5%3 then the result is 2 because the reminder is 2 and if 4%4 its 0 and so on...
22nd Dec 2018, 2:07 PM
Michael Mamo
Michael Mamo - avatar
+ 2
Modulo in c++ It bascically calculates the remainder . Used to separate the individual digits of a number. Like 5546 % 10=6. This is quite useful in several programs.
22nd Dec 2018, 4:14 PM
Subharthi Paul
+ 2
In python it works as a reminder 9%7= 2 mean how many times does 7 enters into 9, is 1 remainder 2 Example 10 % 3 = 1
23rd Dec 2018, 8:14 PM
patrick kojo barkoh
patrick kojo barkoh - avatar
+ 1
Mohit the coder (M.S.D) Is it true for every numbers?
22nd Dec 2018, 7:29 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Yes, it is the % character is called "the modulo". This is the remainder from doing a division. When the division has no remainder the % =0, else it will always contain a number. 1. 9/3=3 with a modulo of 0 2. 9/2= 4 with a remainder of 1, thus the modulo (%) is 1. 3. 9/-2= -4 with a remainder of 1, thus the modulo (%) is 1. Please let me know if you need any further assistance. A Google Search returns multiple resources.
22nd Dec 2018, 5:06 PM
David F. Rose
David F. Rose - avatar
0
When diving into programming, it’s easy to get caught up in different terms that might not be clear at first. The word “mean” can have several meanings depending on the context—whether it’s shorthand for “mean” in statistics or part of a larger function like the “mean” method in certain languages. It’s important to fully understand the context. For anyone who’s unsure about terms or even looking for help with hiring offshore developers https://talmatic.com/offshore-developers/ who are familiar with complex terminology and coding structures, I found a great resource that could help: Talmatic. They’ve been a solid go-to for companies that need reliable and skilled developers. Worth checking out!
16th May 2025, 11:23 AM
Dmytro Makovetskyi
Dmytro Makovetskyi - avatar
- 2
"%" sign called the Modulus Operator. It returns the remainder of simple integer division.
25th Dec 2018, 3:09 PM
M.N. Sadik
M.N. Sadik - avatar