Hi developers :)
Actually, I'd like to introduce myself first, I'm Mohd. *Computer Engineer* still student :/
Actually, I really like this community, and I think I'll be active in the C++ section as I like it xDD
back to my question :) Please can anyone help me doing this code?
"How to implement a good to use this method (x^8) = ( x^4 )^2, (x^4) = (x^2)^2 and x^2 = x * x.
how to improve the code to do this? instead of using the recursion"
Here's what I did! and then got stuck@@ actually I don't know how can I find the plan to start!!
this is my code for now:
#include <iostream>
using namespace std;
// Function definition
int findPower ( int, int );
// Begin function main
int main()
{
int n;
int x;
cout << "Enter an integer: ";
cin >> x;
cout << "\nEnter the power 'n' (example: x^n): ";
cin >> n;
cout << endl;
if( n%2 == 0 )
{
for( int i = 1; i <= n; i++ )
return 0; // to indicate successfully termination
} // end main
first of all, I just initiate the function definition, thought I'll use a function as what we did in recursion.
so please, anyone can help?
by the way, it is written in the question (Hint: A special case is needed for odd exponents).
thanks in advance :)