Minggu, 22 Maret 2015

Tugas Mentor 1

Program Untuk Mencari Faktorial

  • Raptor



  • C++

#include <iostream>
#include <string>

using namespace std;
class faktor{
int n;
int total; 
public:
faktor();
void input();
void proses();
void output();
};

faktor::faktor(){
cout<< "---------Program Faktorial--------- " <<endl;
}

void faktor::input(){
cout<< "Masukan Faktorial : ";cin>>n;
}

void faktor::proses(){
  total = 1;
cout<< n << "! = ";
for(int i=n;i>0;i--){
  total = total*i;
    cout<< i;
  if(i!=1){
  cout<< "x";
}
}
}

void faktor::output(){
cout<<endl<< "Hasil : " <<total; 
}

int main(int argc, char** argv) {
 faktor x;
 x.input();
 x.proses();
 x.output();

 return 0;
}
Posted on by Unknown | No comments

0 komentar:

Posting Komentar