Write the program for fibonacci in c++?
Answer Posted / 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 |
Post New Answer View All Answers
What is function overloading in C++?
What is the difference between strcpy() and strncpy()?
What is the difference between interpreters and compilers?
Is swift faster than c++?
What is the difference between global variables and local variable
What is the use of main function in c++?
What do you mean by const correctness?
What is the purpose of the "delete" operator?
What is &x in c++?
What is a class template?
How would perform Pattern Matching in C++?
What are enumerations?
What is the use of object in c++?
What is scope operator in c++?
Explain selection sorting. Also write an example.