bharat


{ City } ghaziabad
< Country > india
* Profession * student
User No # 119980
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 1
Users Marked my Answers as Wrong # 0
Questions / { bharat }
Questions Answers Category Views Company eMail




Answers / { bharat }

Question { Wipro, 39327 }

Write the program for fibonacci in c++?


Answer

Simplest one:

#include

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