I'm totally new in C and have a problem in computing. The case is I need to have a 30% off on a number that the user has specified.
for example,
An item is worth 250
How will I compute it to have 30% off?
Sorry, I'm really new in programming.
a novice problem
Started by manipulator, Jun 05 2009 01:43 AM
3 replies to this topic
#1
Posted 05 June 2009 - 01:43 AM
|
|
|
#2
Posted 05 June 2009 - 07:27 AM
Multiply by 0.7.
#3
Posted 05 June 2009 - 07:30 AM
Because:
100% = 100/100 = 1.0
you want 70% of the original number -> 70/100 = 0.7
In case you didn't know...
100% = 100/100 = 1.0
you want 70% of the original number -> 70/100 = 0.7
In case you didn't know...
a *= 0.7;
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#4
Posted 09 June 2009 - 12:02 AM
Note that if a is an integer, the decimal will get lopped off, not rounded to the nearest whole number.
sudo rm -rf /


Sign In
Create Account

Back to top









