View difference between Paste ID: 5PgCsHpg and 71CjzYQJ
SHOW: | | - or go back to the newest paste.
1-
/* 
1+
2-
 * File:   main.cpp
2+
3-
 * Author: Vipar
3+
4-
 *
4+
5-
 * Created on August 28, 2012, 5:30 PM
5+
6-
 */
6+
7
8
int exponent(uint b, uint e) {
9
    if(e == 1) {
10
        return b;
11
    } else {
12
        return b * exponent(b, (e - 1));
13
    }
14
}
15
16
int main() {
17
    cout << "Welcome to the Exponent Calculator." << endl;
18
    cout << "Please put a base (15 max): ";
19
    cin >> base;
20
    cout << "Please put an exponent (15 max): ";
21
    cin >> power;
22
    result = exponent(base, power);
23
    cout << "The result of " << base << "^" << power << " is: " << result;
24
    
25
    return 0;
26
}