RANK PROGRAMS WITH RECURSION

Functions in C + + can be used rekursi.artinya something funfsi can call a function that is himself. Application of such recursion to calculate a value with n positive integer solution of this problem include:

       If n = 1 then x ^ n = x
        other than that: x ^ n = x * x ^ n and its rank in less 1

His example:
       x = 2 and n = 3, its solving process as follows:
        2 ^ 3 = 2 * 2 ^ 2
Or more clearly observe and understand the following programs.

# include <iostream>
# include <conio.h>

long int power (int x, int y);
void main () {
int x, y;

    clrscr ();             // Delete comment
    court <<"\ t \ tSlamet Islan Al Hidayah" <<endl;
    court <<"\ t \ t 10018075" <<endl;
    court <<endl;
    court <<"x ^ y Calculating Program Using Rekrusi" <<endl;
    court <<endl;
    court <<endl;
    court <<"Input x =";
    cin>> x;
    court <<"Input y =";
    cin>> y;
    court <<endl;
    court <<x <<"^" <<y <<"=" <<rank (x, y) <<endl;
    }

long int power (int x, int n) {
     if (n == 1)
       return (x);
       else
       return (x * power (x, n-1));
    }
Output :


Well that's the program that I can make,,,,,!
If there are less jelass know any mistake, do not hesitate to leave a comment ataun advice. So that I can fix it later terimakasihh over his visit,,
Regards super ..

0 Response to " RANK PROGRAMS WITH RECURSION "