Deret Fibonanci dengan c++

#include <iostream>
#include <conio.h>

using namespace std;

int main(){
    int a=0, b=1, c, i, n;

    cout<<"DERET FIBONANCI"<<endl;
    cout<<"---------------------------"<<endl;
    cout<<"Masukkan deret ke-n : ";
    cin>>n;
    
    cout<<a<<",";      
    for(i=0; i<n-1; i++){
             c=a+b;
             a=c;
             b=a-b;
             cout<<c<<",";                      
    }
    
    getch();
    return 0;    
}

Posted on Mei 23, 2011, in Algoritma & Pemrograman and tagged , , . Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: