Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio>
- #include <stdlib>
- int fibonacci(int deret)
- {
- if (deret==0 || deret==1)
- return deret;
- else
- return fibonacci(deret -1) + fibonacci (deret -2);
- }
- main()
- {
- atas:
- int hasil, deret;
- char ans;
- cout<<"Masukkan Suku Deret ke : "; cin>>deret;
- hasil=fibonacci(deret);
- cout<<"Hasil Deret Fibonacci : "<<hasil<<endl<<endl;
- lagi:
- cout<<"Apakah Anda Ingin Mencoba Lagi [Y/N] : "; cin>>ans;
- if (ans=='y' || ans=='Y')
- { system ("cls"); goto atas;}
- if (ans=='n' || ans=='N')
- { system ("cls"); cout<<"=*= TERIMAKASIH =*="; }
- else { system ("cls"); goto lagi; }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement