IT Solution

Tuesday, 27 August 2013

Program c++ faktorial

August 27, 2013 Posted by Bops No comments
Struktur data (Semester 3)
Faktorial program
poted by: Nazih

#include<iostream>
using namespace std;
        int faktorial(int x){
                int b = 1;
                if(x-1 > 0){
                        b= faktorial(x-1);
                }
                return x * b;
        }
int main(){
        int angka;
        cout << "Masukan angka" << endl;
        cin >> angka;
        int hasil = faktorial(angka);
        cout << angka << " faktorial adalah : "<< hasil << endl;
        return 0;
}

0 comments:

Post a comment

Terimakasih telah bergabung di blog saya.

Featured post

Game PC (BMW M3)