Kamis, 10 April 2014

Membuat fungsi faktorial secara rekursif untuk mencari n!

Analisis :

kasus penyetop (= nilai awal) n=0 atau n = 1 yaitu bernilai konstan 1

      n*faktorial (n-1)

Flowchart :

 


 

Membuat fungsi untuk menghasilkan nilai x^y

Analisis :

Dengan menggunakan sifat logaritma
         ln(x^y) = y*ln(x)

   exp(ln(x^y)) = exp(y*ln(x))

         x^y = exp(y*ln(x))

Flowchart :



Fungsi yang menentukan nilai terbesar dari 2 bilangan bulat

Deskripsi
   if (a > b)then return a
   else return b

Flowchart :


Mencetak bilangan bulat positif yang habis dibagi 3 dan 5 antara 1sampai 100

Deskripsi
nt x=1;
int y=100;
while (!(x==y))
if (x % 3==0 && x % 5==0)
then write ( “Hasilnya : “)
else
x =x+1;

Flowchart :

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes