I have this code to find the power of x^y. i already found out how to do x^y but am having trouble doing x^-y (x to the -y power) Here is my code
Can anyone please give me hints to do x to the -y power?Code:#include <iostream.h>
int main()
{
double x,y;
double sum = 1;
cout << "Enter the X number : ";
cin >> x;
cout << "Enter the Y number : ";
cin >> y;
for (int a =1; a<=y; a++)
{
sum = sum * x;
}
cout << sum << endl;
cin >> hold;
}
Thanks.