I'm bored here's a decimal power-of-2 using simple carry-add. Don't expect your grader to believe you wrote it yourself though.
Code:
#include <iostream>
int main(){
int p=10,*d=new int[p],s=1,b,i,j,c,*t;*d=1;
std::cout<<"Enter a number: ";
std::cin>>b;
for(i=0;c=0,i<b;++i){
for(j=0;j<s;++j){
j[d]+=j[d]+c;
c=j[d]>9?1:0;
j[d]-=j[d]>9?10:0;
}
if(c){
d[s++]=c;
if(s==p){
t=new int[p<<=1];
for(j=0;j<s;++j)j[t]=j[d];
delete[]d,d=t;
}
}
}
std::cout<<"2^"<<b<<"\n";
for(i=s-1;i+1;--i)std::cout<<i[d];
return 0;
}
It can do 2^100000 in 15~20 seconds. I could use binary splitting and Karatsuba/FFT, but hey this is a forum post. Perhaps you'll understand it someday.
Anyway, there is a shortcut. The << operator isn't only for cout. On integers, it shifts bits. (It's called the left shift operator.) Imagine that the number 19 is written in binary: 10011. What the left shift does is, it shifts all the bits left and adds a zero in the empty slot. So you get 100110 for (19 << 1), 1001100 for (19 << 2) and so on. So (2^X) == (1 << X). Have fun.