Kamis, 31 Maret 2016

PEMROGRAMAN FUNGSI FAKTORIAL ( KASUS 5.5 )

1.C++:
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
void factorial (int n, int x, int hasil){
 if(x>n)
 {
  cout<<"Factorial  "<<n<<"  adalah  "<<hasil<<endl; }
 else
 {
  hasil=hasil*x;
  x=x+1;
  factorial(n,x,hasil);
 }
}

int main(int argc, char** argv) {
 int hasil;
 int n;
 int x;
 cout<<"Masukkan nilai factorial : ";
 cin>>n;
 x=1;
 hasil=1;
 factorial(n,x,hasil);
 return 0;
}

2.Raptor :
luvne.com ayeey.com cicicookies.com mbepp.com kumpulanrumusnya.com.com tipscantiknya.com

0 komentar:

Posting Komentar