PROGRAM PERMUTASI MENGGUNAKAN C++

#include <cstdlib>
#include <iostream>

using namespace std;
 int faktorial (int n)
{
    int fak;
    if (n<=1)
    {
    fak=1;
    }
    else
    {
    fak=n*faktorial(n-1);
    }
    return (fak);
}
int main(int argc, char *argv[])
{
     int n,r, Permutasi;
    cout<<" Program Menghitung Permutasi"<<endl;
    cout<<" \n Masukkan Nilai n : "; cin>>n;
    cout<<" \n Masukkan Nilai r : "; cin>>r;
    Permutasi = faktorial (n)/faktorial(n-r);
    printf(" Permutasinya adalah: %d",Permutasi);
    system("PAUSE");
    return EXIT_SUCCESS;
}
Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s