write a function definition to calculate 2^x,where x should be the input to the function.
Plz solve this...
Answers
Answered by
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
History,
6 months ago
English,
6 months ago
Science,
1 year ago
India Languages,
1 year ago
Hindi,
1 year ago