-
alternatives to pow()
Hello,
I'm working on an assignment that requires the user to input a number, and then another number to raise the first one by (like pow() ). The product is then displayed. By the way, this would be incredibly easy with the pow function, but I am not allowed to use it.
I am stumped.
I am not asking anyone to write this for me. In fact, I request that if you offer a solution, don't even give me a code example. Just give me a bit of direction on how to accomplish this with looping (ie what type of looping to use, etc).
Any feedback is appreciated, I'm pretty stuck.
-
Well is it integer based math? If so just use a simple for loop after the input of the second number.
-
yes, it is interger based. Whole numbers only.
-
You could use a for loop that counts from 1 to the number of times the user wants to multiply by (the power),
Have a variable holding the running total, and just multiply the total (good Idea to initialise it as 1) by the base number each time through the loop.
That'd be my first guess...hope it helps
-
I got it. Yes, that helped a lot especially considering I was messing with a total while I read your reply.