Tuesday, December 4, 2012

Dasar-dasar Pemrograman : Function Faktorial

#include <cstdlib>
#include <iostream>

using namespace std;

int factorial(int f){
int hasil=1;

for(int i=1; i<=f; i++){
hasil*=i;
}
return hasil;
}

int main(int argc, char *argv[]){
int x;

cout<<”Masukan bilangan yang akan di factorial : “;
cin>>x;
cout<<x<<”! = “<<factorial(x)<<endl;
system(“PAUSE”);
return EXIT_SUCCESS;

Share this

0 Comment to "Dasar-dasar Pemrograman : Function Faktorial"

Post a Comment