40. program bilangan fibonacci yang sederhana
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a;
int b;
int i;
int suku;
i =1;
a =0;
b =1;
cout << a<<", "<<b<<", "; while (!(i>5))
{
suku =a+b;
cout << suku <<", ";
a =b;
b =suku;
i =i+1;
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a;
int b;
int i;
int suku;
i =1;
a =0;
b =1;
cout << a<<", "<<b<<", "; while (!(i>5))
{
suku =a+b;
cout << suku <<", ";
a =b;
b =suku;
i =i+1;
}
return 0;
}
Komentar
Posting Komentar