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
How a pointer differs from a reference?
What are the storage qualifiers?
How are pointers type-cast?
Why are arrays usually processed with for loop?
Explain pass by value and pass by reference.
Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.
What is flush () in c++?
How do you find out if a linked-list has an end?
What is the difference between function overloading and operator overloading?
What do you understand by pure virtual function? Write about its use?
A prime number is a number which is divisible only by itself and 1. Examples of the first few primes are 2, 3, 5, 7, 11. Consider writing a program which can generate prime numbers for you. Your program should read in and set a maximum prime to generate and a minimum number to start with when looking for primes. This program should be able to perform the following tasks: 1. Read the maximum number from user (keyboard input) to look for primes. The program should not return any primes greater than this number. 2. Read the minimum number from user (keyboard input) to look for primes. The program should not return any primes less than this number. 3. Generate and print out every prime number between the maximum prime and minimum number specified by the user.
Explain unexpected() function?
Explain the concept of copy constructor?
Comment on c++ standard exceptions?
Explain the difference between c++ and java.