Computer Science, asked by krishiganesh, 1 year ago

WRITE A C++ PROGRAM TO GENERATE 15 TERMS OF THE FIBONACCI SERIES.

Answers

Answered by siddhartharao77
6

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.


Hope it helps!

Attachments:
Answered by Siddharta7
8

#include<iostream>

usnig namespace std;

int main()

{

int i,no, first=0, second=1, next;

clrscr();

first=0;

second=1;

cout<<"Enter nubmer of terms for Series: ";

cin>>no;

cout<<"Fibonacci series are: \n";

for(i=0; i<no; i++)

{

cout<<"\n"<<first;

next = first + second;

first = second;

second = next;

}

return 0;

}


output:

enter number of terms = 15

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597


Hope it helps

Similar questions