Write the program for fibonacci in c++?
Answer Posted / dudelzy
Simplest one:
#include <iostream>
using namespace std;
int main()
{
int x, a = 0, b = 1, i, z;
cout << "Lets Start!" << endl;
cout << "No. of elements in the series = ";
cin >> x;
cout << "Series: " << endl;
for(i = 0; i < x; i++){
z = a + b;
a = b;
b = z;
cout << z << endl;
}
return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?
Write about c++ storage classes?
What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator?
What is the identity function in c++? How is it useful?
What is the difference between global variables and local variable
What do you mean by late binding?
What is operator overloading in c++ example?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What do you mean by global variables?
Write a program to show polymorphism in C++?
What does std mean in c++?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
What is time h in c++?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
What is const in c++?