a 'challenge' question by my teacher asks me to look in my C++ book,
and do a question. it asks me to:

write a function powfun() and make it raise an integer number passed to it to a positive integer power and returns the result to the calling function. it then says declare variable used to return the result as a long integer type.

safe to say, im lost. any inputs would be appreciated.

If you can't solve the problem, try solving a simpler one first.

For example, try writing a function that takes two integers as its arguments and returns their sum as its result. Then try making the function return a long integer.

Hi BryantFury, First I want suggest you that mention your problem facing point rather than just explaining your question.
In in your problem there is two phase
1. Creating a function and
2. Calculating the power

Logic behind calculating the is so simple for example
what happen here 2 multiple it self up to the power
which means 2*2*2*2
so try this by using simle loop
some thing like this

int result =1;

Best Of Luck.

hmm i see. ill work on that and ill post if i get results thanks.

i think im getting there , ive managed to make a function(simplex^2) ones and used them in a program. last question what does 'positive integer power' mean?
does it mean what number i put in, make it a positive?
eg input X output X
input -X output X

or power of itself. ie.
input X output X^X
input -X output X^X

? thnx for the your insights btw

Positive integer power is simply means that N^X here x is positive it not relate to N, N is totally different.Do you know that if power is -ve that means
for example: N^-X is equal to N^(1/X).
So for making this either you take only positive input or convert -ve to +ve by multiplying -1 with -ve no.
to check inputed no. is -ve or +ve you can use


Best Of Luck.

ah i get it. i will need two inputs.
first would be the X and second would be the N.
ill also make the X input become positive via the program. alright thanks a lot.