Hi, Im new to the forums, and very new to C++. I have an assignment for my entry level c++ class that I am having trouble with. What I have to do is written in the title. This is what I have, let me know if you would change anything or if this would even work. The argument must be greater than or equal to zero.
Allow me to comment on the code that you have so far:
1 2 3 4 5 6
int power (int two, int exponent)
{
int zero = 1;
int two = 2;
//...
<- The parameter 'two' is either not necessary or named very, very poorly.
<- This is humorous, at least.
<- This local variable 'two' hides the function parameter 'two'.
The rest of the logic just reads silly because of the variable names. :P
@farcear
Yes, they are, but I only made two changes to the OP's code, which was recursive.
@kyleg033
Just do it, and learn everything you can about what it is you are currently doing.
I started out writing simple utilities (menu systems and the like) and games (breakout clone, hangman, Ladder clone, etc) and utilities to help (pixel editor, dungeon map editor, etc).