习题2-7
![](http://images0.cnblogs.com/blog/570517/201310/30215230-32e931266abe49c5a28f5e03ae0fbb90.png)
#include<stdio.h> #include<math.h> int main(void) { int i,n,sum; printf("Enter n:"); scanf("%d",&n); sum=0; for(i=1;i<=n;i++){ sum=sum+pow(2,i); } printf("result=%d\n",sum); return 0; }
#include<stdio.h> #include<math.h> int main(void) { int i,n,sum; printf("Enter n:"); scanf("%d",&n); sum=0; for(i=1;i<=n;i++){ sum=sum+pow(2,i); } printf("result=%d\n",sum); return 0; }