English

Write Program in C++ to Print First 20 Terms of Fibonacci Series (Series Is 0, 1, 1, 2, 3, 5, 8 .......... ) - Computer Science 1

Advertisements
Advertisements

Question

Write program in C++ to print first 20 terms of Fibonacci Series (Series is 0, 1, 1, 2, 3, 5, 8 .......... )

Short Note

Solution

//Program to generate 20 terms of fibbonacci series 
#include <iostream.h>
void main()
{
  int f0, f1, f, n;
  f0 = 0;
  f1 = 1;

  cout <<"Fibbonacci Series :";
  cout << f0;
  cout << f1;
  for (n = 2; n < 20; n++)
  {
    f = f0 + f1;
    cout << f;
    f0 = f1;
    f1 = f;
  }
}​
shaalaa.com
C++ Programming
  Is there an error in this question or solution?
2015-2016 (March)

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×