हिंदी

Write a C++ program to display a series of 15 term of the Fibonacci Series. - Computer Science 1

Advertisements
Advertisements

प्रश्न

Write a C++ program to display a series of 15 term of the Fibonacci Series.

संक्षेप में उत्तर

उत्तर

Sample Program to generate 15 terms of Fibonacci series:

#include<iostream>

using namespace std;

int main()

{

int a = 0, b = 1, c;

cout<< " Fibonacci series : ";

cout<<a<<" "<<b;

for(int i = 0;i<=15;i++)

{

c = a + b;

cout<<" "<<c;

a = b;

b = c;

}

return 0;

}


Output:

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597.

shaalaa.com
C++ Programming
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2016-2017 (March)

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×