Write the program for fibonacci in c++?

Answer Posted / ria

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr ();
int n,f1,f2,f3,i;
cout<<"/n input the no.of terms";
cin>>n;
f1=-1;
f2=1;
cout<<"/n the fibonacci series is ";
for(i=1,i<=n,i++)
{
f3=f1+f2;
cout<<"/n"<<f3;
f1=f2;
f2=f3;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Mention the storage classes in c++.

645


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1853


What is the size of a vector?

575


What is c++ try block?

577


You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()

586






What does floor mean in c++?

578


Describe public access specifiers?

579


What is c++ stringstream?

601


Can member functions be private?

591


What is a multiset c++?

547


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

614


why is iostream::eof inside a loop condition considered wrong?

589


What is the role of copy constructor in copying of thrown objects?

593


Explain the uses oof nested class?

623


What is an iterator?

684