Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write the program for fibonacci in c++?

Answers were Sorted based on User's Feedback



Write the program for fibonacci in c++?..

Answer / kishor niit ottapalam

#include<iostream>
int main()
{
int x,y;
x=y=1;
while (x<200)
{
cout<<y<<endl;
x=x+y;
y=x-y;
}
return 0;
}

Is This Answer Correct ?    119 Yes 82 No

Write the program for fibonacci in c++?..

Answer / smita

#include<iostream.h>
#include<conio.h>
class fibonacci
{
int f0,f1,f2;
public:
fibonacci()//constructor
{
f0=0;
f1=1;
f2=f0+f1;
}

void cal()
{
f0=f1;
f1=f2;
f2=f0+f1;
}
void dis()
{
cout<<"fibonacci:"<<f2<<endl;
}

};
void main()
{
fibonacci obj;
int n;
cout<<"How many no. displayed:"<<endl;
cin>>n;
for(int i=0;i<=n-1;i++)
{

obj.dis();
obj.cal();
}

getch();
}

Is This Answer Correct ?    57 Yes 34 No

Write the program for fibonacci in c++?..

Answer / bharghavi

#include<iostream.h>
void main()
{
int a=-1;b=1,c;
for(int i=0;i<200;i++)
{
c=a+b;
cout<<c<<"\t";
a=b;
b=c;
}

Is This Answer Correct ?    83 Yes 65 No

Write the program for fibonacci in c++?..

Answer / jitendra goyal

#include<stdio.h>
#include<conio.h>
main()
{
int a=0,b=1,n,c;
printf("how many element you want in series");
scanf("%d",&n);
printf("%d%d",a,b);
for(i=0;i<=n-2;i++)
{
c=a+b;
print("%d",c);
a=b;
b=c;
}
getch();
}

Is This Answer Correct ?    5 Yes 1 No

Write the program for fibonacci in c++?..

Answer / gobinath

#include<iostream>
using namespace std;
class A
{
public:
void print()
{
int a=0,b=1,c=0,n;
cout<<"Enter the number of : "<<endl;
cin>>n;
cout<<a<<" "<<b<<" ";
for(int i=1;i<=n-2;i++)
{
c=a+b;
a=b;
b=c;
cout<<c<<" ";
}
}
};
int main()
{
A a;
a.print();
}

Is This Answer Correct ?    2 Yes 0 No

Write the program for fibonacci in c++?..

Answer / ria

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr ();
int n,f1,f2,f3,i;
cout<<"/n input the no.of terms";
cin>>n;
f1=-1;
f2=1;
cout<<"/n the fibonacci series is ";
for(i=1,i<=n,i++)
{
f3=f1+f2;
cout<<"/n"<<f3;
f1=f2;
f2=f3;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No

Write the program for fibonacci in c++?..

Answer / irushad abdulrahman

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a=-1, b=1, c, x;
cout << "Enter a number to find FIBONACCI less than
that:";
cin >>x;
do
{
c=a+b;
cout << c << "\t";
a=b;
b=c;
}
while (c<=(x-c));
cout <<"\n";

system ("pause");
return 0;
}

Is This Answer Correct ?    2 Yes 1 No

Write the program for fibonacci in c++?..

Answer / srinivasan

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=0,b=1,c=0,n;
cout<<"Enter the number: ";
cin>>n;
cout<<a<<" "<<b<<" ";
for(int i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
cout<<c<<" ";
}
getch();
}

Is This Answer Correct ?    3 Yes 2 No

Write the program for fibonacci in c++?..

Answer / joy

#include<iostream.h>
#include<conio.h>
voidmain()
{
clrscr();
int f1=0,f2=1,f3,n,i;
cout<<"Enter the number of terms...";
cin>>n;
cout<<"Fibonacci Series\n";
cout<<f1<<'\n'<<f2<<'\n';
for(i=3;i<=n;i++)
{
f3=f1+f2;
cout<<f3<<'\n';
f1=f2;
f2=f3;
}
getch();
}

Is This Answer Correct ?    3 Yes 2 No

Write the program for fibonacci in c++?..

Answer / gobicsk

#include <iostream>
using namespace std;

const int n = 20;
long result[n];

int fibonacci( int m )
{
if( result[m] > 0 )
// We already computed it.
return result[m];

int answer;

if( m == 0 )
answer = 0;
else
if( m == 1 )
answer = 1;
else
answer = fibonacci( m - 1 ) + fibonacci( m - 2 );

// Save answer for re-use.
result[m] = answer;
return answer;
}

int main()
{
fibonacci( n );

cout << "\n Fibonacci Series \n";

for( int i = 0; i <= n; i++ )
cout << "\n Fibonacci(" << i << ") = " << result[i];

}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is a .h file c++?

0 Answers  


Write a C++ program which will compute the volume of a sphere or a cylinder after prompting the user to type the first character for the shape name.

0 Answers   An-Najah National University,


What can I use instead of namespace std?

0 Answers  


What operator is used to access a struct through a pointer a) >> b) -> c) *

0 Answers  


What is scope resolution operator in c++ with example?

0 Answers  


What are destructors?

0 Answers  


What are literals in C++?

0 Answers   Wipro,


Is there a sort function in c++?

0 Answers  


What are virtual constructors/destructors?

0 Answers  


What is the difference between global variables and local variable

0 Answers  


how many controls can we place on single form.

1 Answers   Microsoft,


Is c++ a low level language?

0 Answers  


Categories