I explained that first factorial numbers. Example, say you find number 4 then the process:
4!=4*3*2*1yes, the results of 4! is 24.
4!=24
I am following the literature of the algorithm in advance;
Algoritma:
declaration:
n,faktor : integer
description:sourcecode:
read n
faktor<--1
for i<--1 to n do
faktor*<--i
write faktor
#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<<"http://yt-yusufruli.blogspot.com"; } int main(){ fakt x; x.masukan(); x.proses(); getch(); return 0; }
0 komentar:
Post a Comment