Selasa, 30 Juni 2015

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 :


Related Posts:

  • C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)C++ PROGRAM BILANGAN (terbesar, terkecil, rerata) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char … Read More
  • 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 … Read More
  • C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL ( CLASS ) C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL  ( CLASS ) #include <iostream> #include <cstdlib> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") o… Read More
  • C++ PROGRAM PANGKAT (REKURSIF) C++  PROGRAM PANGKAT (REKURSIF) #include <iostream> #include <cstdlib> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int pangkat(… Read More
  • C++ Program Konversi Nilai UjianC++ Program Konversi Nilai Ujian #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { … Read More

0 komentar:

Posting Komentar