Chemistry, asked by vyomgupta, 11 months ago

write a c++ program to print the following numbers in a series 0 1 1 2 3 5 8 13....... n( fibonnaci series)


vyomgupta: good morning
vyomgupta: hii
vyomgupta: hii ruppanzel
vyomgupta: Fine nd u
vyomgupta: hmm
vyomgupta: dnr ho gaya

Answers

Answered by Chickblast
4

#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;

}

Answered by ruppunzel7275
5

I hope this answer may help you...

#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;


}

Similar questions