Factorial c++

This is my factorial program yesterday during math exams deskrit response. I do sort of like this ..

I explained that first factorial numbers. Example, say you find number 4 then the process:

4!=4*3*2*1

4!=24

yes, the results of 4! is 24.

I am following the literature of the algorithm in advance;

Algoritma:

declaration:

n,faktor : integer

description:

read n

faktor<–1

for i<–1 to n do

faktor*<–i

write faktor

sourcecode:

#include <iostream.h>
#include <conio.h>

class fakt{
public:
masukan();
proses();
private:
int n,faktor;
};

fakt::masukan(){
cout<<"\t\tProgram factorial"<<endl;
cout<<"Masukan yang akan di factorialkan = ";
cin>>n;
}

fakt::proses(){
faktor=1;
for(int i=1;i<=n;i++){
faktor*=i;
}
cout<<"Faktor dari "<<n<<"! = "<<faktor<<endl<<endl;
cout<<"https://yusufruli.wordpress.com";
}

int main(){
fakt x;
x.masukan();
x.proses();
getch();
return 0;
}

Posted on Juli 8, 2011, in Alprog. Bookmark the permalink. Tinggalkan komentar.

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 )

Foto Google+

You are commenting using your Google+ 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 )

Connecting to %s

%d blogger menyukai ini: