Advertisements
Advertisements
Question
Write a C++ program to display a series of 15 term of the Fibonacci Series.
Answer in Brief
Solution
Sample Program to generate 15 terms of Fibonacci series:
#include<iostream>
using namespace std;
int main()
{
int a = 0, b = 1, c;
cout<< " Fibonacci series : ";
cout<<a<<" "<<b;
for(int i = 0;i<=15;i++)
{
c = a + b;
cout<<" "<<c;
a = b;
b = c;
}
return 0;
}
Output:
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597.
shaalaa.com
C++ Programming
Is there an error in this question or solution?