#include <iostream.h>
#include<conio.h>
main()
{
int x=1,y=1,p,i,a;
clrscr();
cout<<"Masukkan batas deret fibonacci : ";
cin>>a;
cout<<x<<" ";
cout<<y<<" ";
for(i=0;i<=a-3;i++)
{
p=x+y;
cout<<p<<" ";
x=y;
y=p;
}
getch();
return 0;
}
Belajar Blogging, Pemrograman C++, Turbo Pascal
#include <iostream.h>
#include<conio.h>
main()
{
int x=1,y=1,p,i,a;
clrscr();
cout<<"Masukkan batas deret fibonacci : ";
cin>>a;
cout<<x<<" ";
cout<<y<<" ";
for(i=0;i<=a-3;i++)
{
p=x+y;
cout<<p<<" ";
x=y;
y=p;
}
getch();
return 0;
}
0 comments:
Post a Comment