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 are inline functions? What is the syntax for defining an inline function?
What is the extension of c++?
what is data encapsulation in C++?
What is object oriented programming (oop)?
What is singleton class in c++?
Why pointer is used in c++?
Write a program which uses Command Line Arguments
What do you mean by public protected and private in c++?
How much maximum can you allocate in a single call to malloc()?
What is the difference between struct and class?
What are protected members in c++?
Why can templates only be implemented in the header file?
What are default parameters? How are they evaluated in c++ function?
What is function overloading c++?
Why cout is used in c++?