Wednesday, December 1, 2010
C++
Program Faktorial
#include <iostream.h>
#include <conio.h>
int main ()
{
int i, n, f=1;
cout<<"Masukkan bilangan positif : ";
cin >>n;
cout<<n<<" faktorial = ";
for (i=2; i<=n; i++) {
f *= i;
}
cout<<f<<endl;
int fa=1;
i=2;
cout<<n<<" faktorial = ";
while (i<=n){
fa *= i;
i++;
}
cout<<fa<<endl;
int fb=1;
i = 2;
cout<<n<<" faktorial = ";
do {
fb *= i;
i++;
} while (i<=n);
cout<<fb<<endl;
getch ();
return 0;
}
0 Response to " Program Faktorial "
Post a Comment