Computer Science, asked by stardust506, 1 year ago

write a function definition to calculate 2^x,where x should be the input to the function.
Plz solve this...

Answers

Answered by deepanshugarg58
1

I will do it using C++

#include<iostream>

#include<math.h>

using namespace std;

class n{

   int x;

   public:

       void getdata(){

           cout<<"Enter x";

           cin>>x;

       }

       void calculate(){

           int ans = pow(2,x);

           

           cout<<ans;

       }

};


int main(){

   n n1;

   n1.getdata();

   n1.calculate();

   return 0;

}

Similar questions