View difference between Paste ID: f4HuwLBr and 5PgCsHpg
SHOW: | | - or go back to the newest paste.
1
#include <cstdlib>
2
#include <iostream>
3
4
using namespace std;
5
6
uint base, power, result;
7
8-
int exponent(uint b, uint e) {
8+
uint 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): ";
18+
    cout << "Please put a base: ";
19
    cin >> base;
20-
    cout << "Please put an exponent (15 max): ";
20+
    cout << "Please put an exponent : ";
21
    cin >> power;
22
    result = exponent(base, power);
23
    cout << "The result of " << base << "^" << power << " is: " << result;
24
    
25
    return 0;
26
}