Advertisement
fvzy

Calculator Faktorial

Nov 21st, 2012
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. //Ini adalah Fungsi-nya
  3. using namespace std;
  4. float factorial(float n)
  5. {
  6.  
  7. if(n>1)
  8. return n*factorial(n-1);
  9. else
  10. return 1;
  11. }
  12. main()
  13. {
  14.  
  15. float fac,n;
  16. //title
  17. cout<<"\t\t$-----------------------------------$"<<endl;
  18. cout<<"\t\t|CONTOH PROGRAM CALCULATOR FAKTORIAL|"<<endl;
  19. cout<<"\t\t| by : ageung hidayat |"<<endl;
  20. cout<<"\t\t$-------$-------*****-------$-------$"<<endl;
  21. cout<<"\nMasukkan Angka: ";
  22. cin>>n;
  23. //output
  24. cout<<"Faktorial dari "<<n<<" adalah "<<factorial(n)<<endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement