WAP to perform the following task by using only mathematical functions: Find and print 3 raised to the power 5. Assign 3 and 5 to suitable variables
Answers
Answered by
1
Explanation:
C++ program to calculate pow(x,n)
#include<iostream>
using namespace std;
class gfg
{
/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}
};
/* Driver code */
int main()
{
Similar questions
Social Sciences,
2 months ago
English,
2 months ago
English,
2 months ago
Math,
4 months ago
Science,
10 months ago
Business Studies,
10 months ago