Posted in Programming

Pemrograman C++ : Program Deret Fibonacci (Bukan Metode Array)

 

fibonacci

Kode :

#include <iostream>
using namespace std;
int main()
{
int f1, f2, f0, n;
f1=0;
f2=0;
cout<<“Masukkan jumlah angka : “; cin>>n;
cout<<“Masukkan angka ke-1 : “; cin>>f1;
cout<<“Masukkan angka ke-2 : “; cin>>f2;

cout<<endl<<“Deret Fibonacci : “<<endl;
for(int i=0; i<n; i++)
{
cout<<f1<<” “;
f0=f1+f2;
f1=f2;
f2=f0;
}
}

 

Advertisements

Author:

I'm just a simple guy..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s