Thread: Base Power Program

  1. #1
    Registered User
    Join Date
    Feb 2016
    Posts
    15

    Base Power Program

    Hello Guys,
    I need Some Help From your Side.
    I have to make a program that Calculates
    Base & Power (In Decimal)
    For Example : 2^2.5
    I Know how to code but dont know what logic should i use for that .
    Can Someone Help me ? (without using pow(a,b) or sqrt(a,b) or math.h directory)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Can you use logarithms?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by Salem View Post
    Can you use logarithms?
    No Brother ..

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    1. Would you be able to do this if the exponents were limited to integers (whole numbers)?
    2. Are there restrictions on the possible values of the exponent?

  5. #5
    Registered User
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by Matticus View Post
    1. Would you be able to do this if the exponents were limited to integers (whole numbers)?
    2. Are there restrictions on the possible values of the exponent?
    1. Its Not Necessary to solve it if the exponent is integer..
    2. No,there are no Restrictions on that .
    Its just a Program that takes Base and power From the User .. Its even acceptable if it doesnt calculate integer value ...
    it should be Like pow(x,y) Fuction In C Programming .. that Takes Base and Power and Calculate it..

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    I suppose some search terms like "calculate exponent by hand" would show you some actual algorithms you could implement.

    Or you could research how to calculate logarithms by hand, implement that, then use your own logarithm code to calculate powers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Possibly the "real" task is to implement a natural log function and the pow() is just a distraction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question about base 10 to base N convertor lab program
    By ethankins in forum C++ Programming
    Replies: 4
    Last Post: 12-01-2010, 10:42 AM
  2. [First Program] Base Convertor
    By cwn723 in forum C++ Programming
    Replies: 5
    Last Post: 05-06-2010, 06:25 PM
  3. Replies: 5
    Last Post: 07-25-2008, 04:37 AM
  4. Change of base program
    By cdonlan in forum C Programming
    Replies: 2
    Last Post: 01-17-2005, 04:51 PM
  5. sine C program with Power Series
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-08-2001, 10:46 AM