My question is how do I compute 2^(x) in c. I know there is something like shifting that does the same thing. I tried to do total = x << 1, but that didn't work. I know that if i shift one bit it is the same as multiplying it by two. Or something like that.
int x;
for(x=0; x<4; x++){
total += x <<1; //
}
When this is done executing I expect the total to be 15 ( 20 + 21 + 22 + 23 )
Any ideas on what I am doing wrong? my total starts off as being 0 and then messes up.
Thanks!