+ 1

Is this code correct for printing a percentage ?!

https://code.sololearn.com/ccLPPQLP5Xxu/?ref=app

8th Aug 2023, 2:12 AM
Kilometers Inmorales
Kilometers Inmorales - avatar
2 Respostas
+ 5
Kilometers Inmorales the linked code has it correct. If you are trying to find x percentage of price y, then (y*x/100) will do it. To remember this, consider the root meaning of the word: Per Cent means Per 100. Per implies division, so... divide... x by 100. That gives you the decimal version of a percent. Now multiply by the price, y, that you want to change by x percent. ("by" implies multiply). y*x/100 That gives you the new price adjusted by the percent.
8th Aug 2023, 2:58 AM
Brian
Brian - avatar
+ 1
Isn't it supposed to be (x / y * 100) where x is perc ?!
8th Aug 2023, 2:13 AM
Kilometers Inmorales
Kilometers Inmorales - avatar