BERIKUT SKRIP C++ PROGRAM FUNGSI
#include <iostream.h>
#include <string.h>
//prototipe fungsi
long faktorial(int m);
int main()
{
cout<<"4! = "<<faktorial(4)<<endl;
cout<<"10! = "<<faktorial(10)<<endl;
return 0;
}
long faktorial(int m)
{
if(m==0)
return 1;
else
return m * faktorial (m-1);
}
HASIL OUTPUTNYA
No comments:
Post a Comment