#include <iostream.h>
#include<conio.h>
#define true 1
int main()
{
long batas;
cout << "Masukkan integer positif : ";
cin >> batas;
cout << "Bilangan Fibonacci < " << batas << ":\n0, 1";
long f1=0, f2=1;
while (true)
{ long f3 = f2 + f1;
if (f3 > batas) break; // menghentikan loop
cout << ", " << f3;
f1 = f2;
f2 = f3;
}
getch ();
return 0;
}
Hasil: