Question #23735

write a program which inputs a positive integer n and output 2 raised to the power of n.

Expert's answer

#include<iostream>

using namespace std;

&

int main (){

int a,i,p=1;

cout<<"Enter a positive integer n : ";

cin>>a;

for (i=0;i<a;i++)

p*=2;

cout<<" 2 raised to the power of n :"<<p<<endl; &

&

system("PAUSE"); &

}

using namespace std;

&

int main (){

int a,i,p=1;

cout<<"Enter a positive integer n : ";

cin>>a;

for (i=0;i<a;i++)

p*=2;

cout<<" 2 raised to the power of n :"<<p<<endl; &

&

system("PAUSE"); &

}

## Comments

## Leave a comment