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 / nitish kumar nirala

#include<iostream.h>
#include<conio.h>
int fibo(int);
void main()
{
int n,fibbon;
cin>>n;//input number to find fabbonic series
fibbo=fibo(n);
cout<<fibbo<<"
";
getch();
}
int fibo(n)
{
if(n==0)
{
return 0;
}
elseif(n==1)
{
return 1;
}
else
{
return(fibo(n-1)+fibo(n-2));
}
}

Is This Answer Correct ?    1 Yes 0 No

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

Answer / dudelzy

Simplest one:

#include <iostream>

using namespace std;

int main()
{
int x, a = 0, b = 1, i, z;
cout << "Lets Start!" << endl;
cout << "No. of elements in the series = ";
cin >> x;
cout << "Series: " << endl;
for(i = 0; i < x; i++){
z = a + b;
a = b;
b = z;
cout << z << endl;
}

return 0;
}

Is This Answer Correct ?    1 Yes 0 No

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

Answer / psrthipan j

#include<iostream.h>
int main()
{
int x,y;
x=y=1;
while(x<20)
{
cout<<y<<end 1;
x=x+y;
y=x-y;
}
return 0;
}

Is This Answer Correct ?    1 Yes 2 No

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

Answer / tanneru chetan

#include<iostream.h>
#include<process.h>
#include<conio.h>
void main()
{
clrscr();
Start:
int n,a=0,b=1,c=0,i=1;
char w;
cout<<"Enter an positive integer to represnt the
nth term of the fibonnaci series: "<<endl;
cin>>n;
cout<<"The fibonacci series upto the "<<n<<"th term
is:"<<endl;
cout<<0<<endl<<1<<endl;
while(i<=n)
{
c=a+b;
cout<<c<<endl;
a=b;
b=c;
++i;
}
cout<<"Do you want to try again(Y/N):"<<endl;
cin>>w;
if(w=='Y' || w=='y')
{
goto Start;
}
else
{
exit(4);
}
getch();
}

Is This Answer Correct ?    14 Yes 17 No

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

Answer / terah njehia

#include<iostream>
#include<iomanip>
using namespace std;

int fn1 = 0, fn2 = 1;
int nextfib(int* fib1, int* fib2)
{
long int next = *fib1 + *fib2;
*fib1 = *fib2;
*fib2 = next;
cout<<setw(3)<<next<<endl;
return 0;
}

int main()
{
int n;
cout<<"Enter the value n of fibonacci numbers you want to
print"<<endl;
cin>>n;
int newn = n - 2;
cout<<setw(3)<<fn1<<setw(3)<<fn2;
for (int index = 1; index <= newn; index++){
nextfib(&fn1, &fn2);
}
return 0;
}

Is This Answer Correct ?    11 Yes 15 No

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

Answer / abhilash

int main()
{
unsigned int i=0,j=0,sum=1,num;
printf("nEnter the limit for the series ");
scanf("%d",&num);
while(sum<num)
{
printf("%d ",sum);
i=j;
j=sum;
sum=i+j;

}


getch();
}

Is This Answer Correct ?    14 Yes 27 No

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

Answer / n.muthukumar

#include

int main()
{
unsigned int i=0,j=0,sum=1,num;
printf("nEnter the limit for the series ");
scanf("%d",&num);

printf("%d",i);
while(sum
{
printf("%d ",sum);
i=j;
j=sum;
sum=i+j;

}



getch();
}

Is This Answer Correct ?    12 Yes 25 No

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

Answer / techbots

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

Is This Answer Correct ?    34 Yes 53 No

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

Answer / raaz

#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{

int range = 0;
cout<<"Enter the range of numbers\n";
cin>>range;

for(int i = 0;i<range;i++)
{

int outNum[100];
if((i==0)||(i==1))
{
outNum[i] = i;
cout<<outNum[i]<<" ";

}
else
{
outNum[i] = outNum[i-1] + outNum[i-2];
cout<<outNum[i]<<" ";

}
}

return 0;
}

Is This Answer Correct ?    13 Yes 33 No

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

Answer / darren chang

int fib(int input)
{
if(input==0)
return 0;
if((input==1)||(input==2))
return 1;
else
return fib(input-1)+fib(input-2);
}

Is This Answer Correct ?    10 Yes 31 No

Post New Answer

More C++ General Interview Questions

the maximum length of a character constant can be a) 2 b) 1 c) 8

0 Answers  


How much is size of struct having 1 char & 1 integer?

11 Answers   Persistent,


Explain deep copy?

0 Answers  


How important is c++?

0 Answers  


Will rust take over c++?

0 Answers  


What do you mean by translation unit?

0 Answers  


daily Routine of father

0 Answers  


How many ways are there to initialize an int with a constant?

1 Answers  


What is abstraction with real time example?

0 Answers  


Is oops and c++ same?

0 Answers  


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

0 Answers  


What are the conditions that have to be met for a condition to be an invariant of the class?

1 Answers  


Categories