Sunday, June 19, 2016

Program sederhana bilangan fibonacci perintah for di dev c++



  • PROGRAM SEDERHANA BILANGAN FIBONACCI
// Taufik Hendriyanto
#include <iostream>
using namespace std;
main()
{
                int suku,a,b,c;
                cout<<"MEMBUAT DERET FIBONACCI"<<endl;
                cout<<"Masukan nilai suku ke-"<<endl;
                cin>>suku;
                cout<<"Bilangannya adalah = "<<endl;
                a=0;b=1;
                cout<<a<<ends<<b<<ends;
                for(int i=3;i<=suku;i++)
                {
                                c=a+b;
                                a=b;
                                b=c;
                                cout<<c<<ends;
                }
                return 0;
}

  • ALGORITMA

{Mencetak deret Fibonacci sesuai dengan inputan yang dimasukan}

0 comments:

Post a Comment