Untitled
unknown
c_cpp
2 years ago
467 B
6
Indexable
#include <iostream>
using namespace std;
double power(double A, int B)
{
if (B == 0)
{
return 1;
}
else {
double result = A;
for (int i = 1; i < B; i++)
{
result *= A;
}
return result;
}
}
int main()
{
double A;
int B;
cin >> A;
cin >> B;
double result = power(A, B);
cout << A << "^" << B << " = " << result << endl;
return 0;
}Editor is loading...
Leave a Comment