LATEST PROGRAMS

WAP in C++ to print the Fibonacci series.

#include<iostream.h>
using namespace std;

int main()
{
    int no_of_terms;
    cout<<"Enter no of terms in fibonacci series :\n";
    cin>>no_of_terms;
    int a=0;
    int b=1;
    int sum;
    cout<<"The fibonacci series is :\n";
    for(int i=1;i<=no_of_terms;i++)
    {
        cout<<a<<"  ";
        sum=a+b;
        a=b;
        b=sum;
    }
    return 0;
}
18/02/2023, 10:54 am Read : 246 times