0% found this document useful (0 votes)
18 views

STD Main N, C, First, Second, Next Endl N N Endl C C N C C Next C

This C++ program defines a Fibonacci series by initializing the first two terms to 0 and 1, then calculates each subsequent term as the sum of the previous two terms. The user inputs the number of terms to be displayed, and the program outputs that number of Fibonacci series terms using a for loop.

Uploaded by

abhi kr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

STD Main N, C, First, Second, Next Endl N N Endl C C N C C Next C

This C++ program defines a Fibonacci series by initializing the first two terms to 0 and 1, then calculates each subsequent term as the sum of the previous two terms. The user inputs the number of terms to be displayed, and the program outputs that number of Fibonacci series terms using a for loop.

Uploaded by

abhi kr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Fibonacci Series

#include<iostream>
using namespace std;
main()
{
int n, c, first = 0, second = 1, next;
cout << "Enter the number of terms of Fibonacci series you want" << endl;
cin >> n;
cout << "First " << n << " terms of Fibonacci series are :- " << endl;
for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
cout << next << endl;
}
}

return 0;

You might also like