C++ Program to Calculate Power of Any Integer Value

Question Types:

Find the power of any give integer value using c++ programming language ?
C++ program code for to calculate a to the power b without using power function ?

Program Code:

#include<iostream>
using namespace std;
int main()
{
double num , pow ,x =1;
cout<<"Enter any integer value :  ";
cin>>num;
cout<<"Enter power of that number :  ";
cin>>pow;
for(int i = 0; i<pow ;i++)
{
x = x * num;
}
cout<<"\n\nAnswer is :  "<<x;
cout<<"\n>>> informativei.blogspot.com";
return 0;
}

Output:


No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.