A.
SCRIPT REKURSIF PROGRAM PENGHITUNG BILANGAN
FAKTORIAL
#include
<iostream>
#include
<conio.h>
using
namespace std;
float
faktorial(int x)
{
if(x==0)
return 1;
else
return x*faktorial(x-1);
}
int
main()
{ char redo;
do
{
int N;
cout<<"Masukan nilai N untuk N!
: ";
cin>>N;
cout<<N<<"!"<<" =
"<<faktorial(N);
cout<<"\n\nUlangi? (y/t):
";
cin>>redo;
}
while (redo=='y' || redo=='Y');
getch();}
Tidak ada komentar:
Posting Komentar