Thread: How to program this math problem

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    24

    How to program this math problem

    Hello cprogramming.com world! :P

    How do I write this math problem in my code?

    X divided by Y to the second power multiplied by 703?

    I tried:

    Code:
     total=(x / y^2) * 703);
    but I get a compile error stating there is a syntax error before the ")" token. I am not sure how/where to put the parenthesis, etc.

    Help

    Thanks!

  2. #2
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    You need to make use of math.h to then be able to use pow(). No need for the paren at the end of your statement or count how many closing and open parens you have, they need to match up.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    Or just do total = 703 * x / (y * y) if you want to avoid using pow() for something this simple.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 11:10 AM
  2. problem w/ doubles in friend's program
    By mkylman in forum C Programming
    Replies: 16
    Last Post: 11-22-2008, 10:45 AM
  3. Problem with my program i cant figure out...
    By youareafever in forum C Programming
    Replies: 7
    Last Post: 11-01-2008, 11:56 PM
  4. Replies: 4
    Last Post: 05-25-2008, 12:31 AM
  5. Problem with simple XOR program
    By spike_ in forum C++ Programming
    Replies: 8
    Last Post: 08-17-2005, 12:09 AM