C++ PROGRAM DERET FIBONACCI ITERATIF

C++ PROGRAM DERET FIBONACCI ITERATIF

#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
void fibonacci(int N){
int U1 = 0, U2 = 1, U3;
for (int i = 0; i<N; i++){
U3 = U1 + U2;
if (i==0){
cout<<U1;
}
else if (i==1){
cout<<", "<<U2;
}
else{
cout<<", "<<U3;
U1 = U2;
U2 = U3;
}
}
}
int main(int argc, char *argv[]) {
int a;
cout<<"===========================================\n";
cout<<"|         PROGRAM DERET FIBONACCI         |\n";
cout<<"|              SRI WAHYUNI                |\n";
cout<<"|              1400018214                 |\n";
cout<<"|            <06 JUNI 2015>               |\n";
cout<<"===========================================\n\n";
cout<<"Masukkan batas : ";
cin>>a;
cout<<"Deret Fibonacci : ";
fibonacci(a);
return 0;}

HASIL COMPILE :


Comments

Popular posts from this blog

Cara Membuat Halaman Login Hotspot Berbeda pada 1 Mikrotik

UltraISO Premium Edition v9.5.3

Arti OSAKMJ