Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

proplem in c++

Options
  • 28-03-2009 1:19pm
    #1
    Closed Accounts Posts: 1


    hi all i am studding c++ now and i have an assgiment to do pi calcution with the fourmila (pi = 4 *( (-1^n)/(2n+1))) now i know to do the power of with the () symbol in c++ the only proplem is the teacher told us not to use the <cmath> libry so if anyone got an answer or an idea to how to do it thank you so much for the help :) it been 3 days now and i am still trying :confused:


Comments

  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Emmmm this is pretty simple maths - x^3 = x*x*x - so x^n is x multiplied by itself n times. Write a little function to perform the power function and feed it the value of x (in this case -1) and n (however many times you want to run the function) and get it to return the result.

    Without trying to be cruel, if you're having issues with problems as simple as this one, perhaps programming is not for you.

    -RD


  • Registered Users Posts: 26,579 ✭✭✭✭Creamy Goodness


    when you want to do something over and over in programming use a loop.

    show us an attempt and people will be a lot more willing to help


  • Registered Users Posts: 4,899 ✭✭✭10000maniacs



    Without trying to be cruel, if you're having issues with problems as simple as this one, perhaps programming is not for you.

    -RD

    Thats what these forums are all about. Sensitive criticism:rolleyes:,Useful help:rolleyes: and career advice:rolleyes: all in the same post.

    Maybe he was looking for something like this.
    http://www.boo.net/~jasonp/pipage.html


Advertisement