Expand|Select|Wrap|Line Numbers
- y=-y;
Expand|Select|Wrap|Line Numbers
- #include<iostream.h>
- using namespace std;
- int main(){
- int x, y;
- float product=1 ;
- cout << "Enter a base number: ";
- cin >> x;
- cout << "Enter an integer exponent: ";
- cin >> y;
- int i = 1;
- if (y<0)
- { y=-y;//HERE I AM
- while (y>=i)
- {
- product *= x;
- i++;
- }
- cout<<x<<"to the power of "<<y<<"equals="<<(1/product);
- }