program c++ perpangkatan (a,n) ke dalam definisi perkalian secara rekursif

pasti lagi cari program untuk referensi tugas ya?
yaudah langsung comot aja source code dibawah ini

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int ubah(int a, int b){
if(b<=1) return a;
else return a*ubah(a,b-1);
}
int main(int argc, char** argv) {
int x,y;
cout<<"Masukan nilai : ";
cin>>x;
cout<<"Masukan pangkat : ";
cin>>y;
cout<<ubah(x,y);
return 0;
}
Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar