Deklarasi :
i,n : integer
faktorial : longint

Deskripsi :
read(n)
faktorial =1
for i=1 to n do
faktorial=faktorial*i
endfor
write(faktorial)

==>Flowchart : 

Image

==> Programnya ; 

#include <iostream.h>
#include <conio.h>
class Operator{
friend ostream& operator<<(ostream&, Operator&);
friend istream& operator>>(istream&, Operator&);
public :
long faktorial();
private:
int n;
long hasil;
};
long Operator::faktorial(){
long fak=1;
for(int=1; i<=n; i++)
fak=fak*i;
return fak;
}
ostream& operator<<(ostream& out, Operator){
a.hasil=a.faktorial();
out<<"Hasil cara iterasi :"<<a.n<<"! adalah "<<a.hasil;
return out;
}
istream& operator>>(istream& in, Operator){
cou<<"Masukkan integer n :";
in>>a.n;
return in;
}
void main(){
Operator run;
cin>>run;
cout<<run;
getch();
}
system ("PAUSE");
return EXIT_SUCCESS;
}

About niehennys

just another girl.

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 )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s