Decimal values


#1

how can i set the variable of 15% of 100 without creating an error for example

tip = 15.0 % 100…

it needs to be in decimal form so how do i compute this before setting the value?


#2

If you want to get a percent of something in a variable, you do it like this:

tax = 100 * 0.08

where 100 is the original price of an item and 0.08(8%) is the percent


#3

The equivalent expression is,

15 / 100  =>  0.15

Eg.

What percentage of 25 is 7?

7 / 25 * 100  =>  0.28 * 100  =>  28%

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.