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 constructor c++?
What are the new features that iso/ansi c++ has added to original c++ specifications?
What do you mean by early binding?
What are the c++ access specifiers?
Explain the pure virtual functions?
What is the main purpose of overloading operators?
Explain the uses oof nested class?
What is a flag in c++?
List the features of oops in c++?
explain the reference variable in c++?
How do you sort a sort function in c++ to sort in descending order?
Can we use clrscr in c++?
Briefly describe a B+ tree. What is bulk loading in it?
What is pointer with example?
Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?