Monday, 30 September 2024

Journal Program 1

 #include<iostream.h>

#include<conio.h>

class Fibo

{

int n;

public :

void getData()

{

cout<<"\n Enter value of n : ";

cin>>n;

}

void putData()

{

int a,b,c,i;

a=1;

b=1;

cout<<a<<"  "<<b<<"  ";

for(i=1;i<(n-1);i++)

{

c=a+b;

a=b;

b=c;

cout<<c<<"  ";

}

}

#include<iostream.h>

#include<conio.h>

class Fibo

{

int n;

public :

void getData()

{

cout<<"\n Enter value of n : ";

cin>>n;

}

void putData()

{

int a,b,c,i;

a=1;

b=1;

cout<<a<<"  "<<b<<"  ";

for(i=1;i<(n-1);i++)

{

c=a+b;

a=b;

b=c;

cout<<c<<"  ";

}

}


};


int main()

{

clrscr();

Fibo f;

f.getData();

f.putData();

getch();

return 0;

}

};


int main()

{

clrscr();

Fibo f;

f.getData();

f.putData();

getch();

return 0;

}


No comments:

Post a Comment