You are on page 1of 2

/*

*Title: power.cpp
*Abstract: C++ program that computes 2 to the nth power
*Author: William Barajas
*ID: 1010
*Date: 5/8/2019
*/

#include <iostream>
using namespace std;

int function(int n)
{
if(n == 0)
{
return 1;
}
else
{
return (2 * function(n-1));
}
}

int main()
{
int num;

cout << "Enter a number: ";


cin >> num;

cout << "Result: " << function(num) << endl;

return 0;
}

You might also like