C++ Programming Tutorial

 
 
 
 

Image

 # include <iostream.h>
 # include    <conio.h>

 const long fibonacci(const int);

 int main()
 {
    clrscr( );

    int number;

    cout<<\"\\n Enter the number = \";
    cin>>number;

    cout<<\"\\n\\n The \"<<number<<\"_th term of fibonacci series = \"<<fibonacci(number);

    getch( );
    return 0;
 }


 //----------------------------  fibonacci( )  ---------------------------//


 const long fibonacci(const int n)
 {
    if(n==0 || n==1)
       return n;

    else
    {
       long fn_1=0;
       long fn_2=1;
       long fn;

       for(int count=2;count<=n;count++)
       {
      fn=(fn_1+fn_2);
      fn_1=fn_2;
      fn_2=fn;
       }

       return fn;
    }
 }

    Related Post:
  1. Program that takes 10 integer from a user and perform addition using class

  2. Program for using enum

  3. Program to perform stack operations using array

  4. Program to illustrate the different features of an array of char known as string

  5. Program to solve the Towers of Hanoi Problem (using Recursive Algorithm)

  6. Program to show the use of Bitwise Operator Left Shift ( &lt;&lt; )

  7. Program to illustrate classes without using inline functions

  8. Program to illusrate comparision operator overloading

  9. Program to illustrate constant objects and constant member functions

  10. Program to read a Non-Linear equation in one variable, then evaluate it using Secant Method and display its kD accurate root

  11. Program of calculator

  12. Program to estimate the value of Fourth Derivative of the function at the given points from the given data using Central Difference Formula of order 2

  13. Program to construct Newtons Divided Difference Interpolation Formula from the given distinct data points and estimate the value of the function

  14. Menu driven telephone directory program

  15. Program to search an element in an array using Linear search or Sequential Search

  16. Program to computes the n_th term of the fibonacci series using Dynamic Programming Technique

  17. Program that provides an example of friend function of a class

  18. Program to estimate the value of First Derivative of the function at the given points from the given data using Central Difference Formula

  19. Program to implement Add and Subtract function on Big Number Class

  20. Library Management System