Solution to Write a c++ program to display the Fibonacci series of the first 50 integer numbers. - Sikademy
Author Image

Archangel Macsika

Write a c++ program to display the Fibonacci series of the first 50 integer numbers.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

#include <iostream>

#include <iomanip>

using namespace std;


int main() {

    long long f1=0, f2=1, f;

    

    cout << setw(2) << 1 << ": " << setw(10) << f1 << endl;

    cout << setw(2) << 2 << ": " << setw(10) << f2 << endl;


    for (int i=3; i<=50; i++) {

        f = f1 + f2;

        f1 = f2;

        f2 = f;

        cout << setw(2) << i << ": " << setw(10) << f2 << endl;

    }


    return 0;

}

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1005-qpid-2