0% found this document useful (0 votes)
10 views2 pages

OOPS Lab File 2

Uploaded by

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

OOPS Lab File 2

Uploaded by

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

Experiment no.

: 2 Date of Experiment :04-02-2023


Name : Ashutosh kumar chaubey Admission No.: 22SCSE1012384

Enrollment No. :22131012234

AIM : Write a C++ program to generate the first n terms of the


sequence of Fibonacci series.

Introduction : A fibonacci sequence is difined as follows the first


and second term in the sequence are 0 and 1. Subsequent terms are
found by adding the proceeding two terms in the sequence.

Algorithm :

• Start
• Declare variables i, a, b, c.
• Initialize the variables, a=0, b=1, and c.
• Enter the number of terms of Fibonacci series to be printed.
• Print First two terms of series.
• Use loop for Fibonacci series.
• End

Source Code :
#include<iostream>
using namespace std;
int main()
{
int a,b,c,n;
a=-1;
b=1;
cout<<"Enter number of terms in a series: ";
cin>>n;
for(int i=0;i<n;i++)
{
c=a+b;
cout<<c<<" ";
a=b;
b=c;

}
return 0;
}

Output : (SCREENSHOT)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy