Tugas Mentoring per#3
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class faktorial{
private:
int bill;
int faktoria;
public:
void input();
void output();
};
void faktorial::input(){
cout<<"masukan yang akan dihitung:";
cin>>bill;
}
void faktorial::output(){
faktoria = 1;
int c=bill;
cout<<c<<"!=";
while(c>=1){
//faktorial=faktorial*c
if(c!=1){
cout<<c<<"x";
faktoria= faktoria*c;
}else{
cout<<c<<"=";
}c--;//menurunkan variabel c
}cout<<faktoria;
}
int main(int argc, char *argv[]) {
faktorial a;
a.input();
a.output();
return 0;
}
ABOUT THE AUTHOR
Hello We are OddThemes, Our name came from the fact that we are UNIQUE. We specialize in designing premium looking fully customizable highly responsive blogger templates. We at OddThemes do carry a philosophy that: Nothing Is Impossible
0 komentar:
Posting Komentar