Jump to content

a novice problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
manipulator

manipulator

    Newbie

  • Members
  • Pip
  • 1 posts
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.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Multiply by 0.7.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Because:
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
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Note that if a is an integer, the decimal will get lopped off, not rounded to the nearest whole number.
sudo rm -rf /