Im a Novice in C++ and Im writting test in few weeks time... have got this question paper and there is something about pow function... when I asked my instructor about it, he just gave me his usually glance and say I must figure it out....well now back to my concern...what is pow function, how does it work, when and where do u use it, have got some information from the net and have heard that is a power something but I dont believe that the info I have got is enough... coz it doesnt really give me an answer to my questions maybe am searching from the wrong sources... if possible I wud appreciate an example with such function

I’m not sure if this time around im being lazy or what…. Have paged my text book from the 1st page to the last one but no lucky I think Massonon hath 4got to include it in his last edition

The following code is a very simple program using the pow function. It is in the cmath library, so you need to make sure you include that. The output for the program would be:

The cube of 4 is 64.

#include <iostream>
#include <cmath>

int main() {

int num = 4, cube;
cube = pow (num, 3);

cout << "The cube of " << num << " is " << cube << ".\n";

return 0;

}

Hope that helps.

This question has already been answered. Start a new discussion instead.