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
What are the characteristics of friend functions?
Explain differences between new() and delete()?
What is an iterator class in c++?
What is the purpose of templates in c++?
Difference between strdup and strcpy?
how to connect with oracle 9i with server in socket program in c/c++
What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?
Which programming language should I learn first?
Is recursion allowed in inline functions?
Explain the difference between struct and class in terms of access modifier.
Can turbo c++ run c program?
Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c
Can I learn c++ without c?
What is the need of a destructor? Explain with the help of an example.
What are the uses of c++ in the real world?