Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Little help here for a noob?

Name: orzo 2007-11-02 22:23

I'm just starting C++ and I'm having the worst time getting this little thing I wrote to run. It's supposed to take two variables from the user, one as a number and another to multiply it to the power of. It compiles fine and everything but when it's supposed to call the function it crashes. Anyone have any ideas why this is? Thanks in advance.

#include <cstdlib>
#include <iostream>

using namespace std;
unsigned int powered(unsigned int, unsigned int);

int main ()
{
    unsigned int number, power, anwser;
   
    cout << "Enter a number: ";
    cin >> number;
    cout << "Enter a power: ";
    cin >> power;
    anwser = powered(number,power);
    cout << "The awnser is: " << anwser << endl;
    char response;
    cin >> response;
    return 0;
}

unsigned int powered(unsigned int a, unsigned int b)
{
         if(a == 1)
         return a;
         else
         return (a * powered(a,b-1));
}

Name: Anonymous 2007-11-02 22:59

>>2
It's the Retard Vigilante! :O
Nobody gives a shit, really. Forced anon only applies to /b/.
In fact, when you're asking a question it's better to use a name, to avoid confusion when more information is needed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List