- Back to Home »
- Source kode algoritma pangkat
#include <cstdlib>
#include <iostream>
using namespace std;
int pangkat(int a, int n){
int k, hasil;
hasil=1;
for(k=1;k<=n;k++){
hasil=hasil*a;
}
return hasil;
}
int main(int argc, char *argv[])
{
int x,y;
cout<<"Masukkan angka : ";
cin>>x;
cout<<endl;
cout<<"Masukkan pangkat : ";
cin>>y;
cout<<endl;
cout<<"Hasil : "<<pangkat(x,y);
cout<<endl;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}