+ 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 !
23 Answers
+ 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.
+ 9
Hi Arb Rahim Badsa,
We called a modulo (percent symbol "%").
+ 7
Was just trying to be helpful. Take it or leave it. It's no skin off my nose.
+ 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
+ 5
Well...as long as you got the information.
+ 4
Yes its true for every number
+ 3
% its gives remainder after doing division operation
9%7 = 2
because 2 remains after divide 9 with 7
+ 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
+ 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 ^^)
+ 3
Thank you very much for the great contribution ! It was very very helpful ! Thanks everyone !
+ 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
+ 2
this can help u
https://cs50.stackexchange.com/questions/
9072/modulo-not-working-in-greedy
+ 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...
+ 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.
+ 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
+ 1
Mohit the coder (M.S.D) Is it true for every numbers?
+ 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.
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!
- 2
"%" sign called the Modulus Operator. It returns the remainder of simple integer division.