Write the program for fibonacci in c++?
Answer Posted / 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 |
Post New Answer View All Answers
What is the limitation of cin while taking input for character array?
What is oops in c++?
How does a copy constructor differs from an overloaded assignment operator?
What is flush c++?
Why is null pointer used?
What are activex and ole?
Where is atoi defined?
What is c++ runtime?
What is iostream in c++ used for?
What is the main function c++?
What is tellg () in c++?
What does std mean in c++?
Can we define a constructor as virtual in c++?
What are c++ data types?
What is scope in c++ with example?