Bahasa : C
Program : Borland C++
5.02
Tentang : Function
Soal :
Buatlah Fungsi
untuk menghitung nilai faktorial suatu bilangan yang ditentukan oleh user.
Jawab :
#include <conio.h>#include <stdio.h>int faktorial (int n);int main(){int n,fak;printf("berapa faktorial? ");scanf("%d",&n);fak = faktorial(n);printf("%d faktorial = %d\n",n,fak);getch();}int faktorial (int n){int i,f=1;if(n<=0)return(0);for (i=2;i<=n;i++) f*=i;return(f);}
Silahkan Tinggalkan komentar anda berupa
pertanyaan, kritik, maupun saran.
1 komentar:
nice for content because help me in homework thank you because with this post my task completed I am very grateful I hope that the next post will be better again I really liked your post !
Posting Komentar