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
Mention the storage classes in c++.
What is the basic concept of c++?
What is wrapper class in c++?
What is fixed in c++?
Can a program run without main function?
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
What is the difference between a declaration and a definition?
Do class declarations end with a semicolon? Do class method definitions?
How are the features of c++ different from c?
What do nonglobal variables default to a) auto b) register c) static
Differentiate between a constructor and a destructor in c++.
Why is swift so fast?
What is long in c++?
What is the use of setfill in c++?
Difference between a homogeneous and a heterogeneous container