Selasa, 30 Juni 2015

PROGRAM FAKTORIAL (C++)

#include <cstdlib>
#include <iostream>

using namespace std;
void faktorial (int n, int &hasil){
if (n>0){
hasil =hasil*n;
faktorial(n-1,hasil);
}
}

int main(){
   int hasil, n;
   cout<<"=================================="<<endl;
   cout<<"      PROGRAM FAKTORIAL       "<<endl;
   cout<<"=================================="<<endl<<endl;
   cout << "Masukkan bilangan : "; cin >> n;

   hasil = 1;

   faktorial(n, hasil);

   cout << n << "! = " << hasil<<endl;
system("pause");
return 0;
}


OUTPUT/HASIL =


Share this

Tag :

0 Comment to "PROGRAM FAKTORIAL (C++)"

Posting Komentar