how to math calculation of percentage? such as: 30 % 4 or 369% 35.
4/6/2020 11:29:56 AM
Shadman Sakib13 Answers
New Answeryou mean in programming? In JavaScript : var a=30; var b=4; document.write(a%b) ; Output: 2 If not, Please provide your problem description clearly..
Math percentages and programming operator % aren't related at all... In computer context, x % y means remainder of the integer division of x by y (named 'modulo' in both math and computer fields). In math context, x% of y means x hundredths of y, in other words: value = float(input()) rate = float(input()) percent = value*rate/100 print(str(rate)+'% of',value,'equals',percent)
It's called modular operator.. Gives you reminder of calculation (a%b) in dividend(a) divided by divisor(b). I included already a example in my first post, see it again..
Shadman Sakib Division operator is / returns quotiont. a=30,b=4 document.write(a/b); this prints 7 Modula operator is % returns reminder. document.write(a%b); this prints 2 A slight difference is calling in programming language.
30% is just 30/100 use that instead when doing calculations then multiply by hundred in the end
Shadman Sakib ok it seems you say an expression like 3 % 4 this means the modulo operator as other people answered https://www.computerhope.com/jargon/m/modulo.htm
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message