Program 8 - CSU1128 - CSE 2026 - Shoolini University

Program to find the nth term of fibonacci series

Code

                    
/*
 * -----------------------------------------------------------
 * Logic Building with Computer Programming (CSU1128P)
 * Instructor: Abdullahi Adem | Author: Divya Mohan
 * 
 * This code is a part of the educational initiative by dmj.one
 * with aim of empowering and inspiring learners in the field of
 * Computer Science and Engineering through the respective courses.
 * 
 * (c) 2022, Divya Mohan for dmj.one. All rights reserved.
 * -----------------------------------------------------------
 */

#include <stdio.h>
int fibonacci();
int main()
{
    int n;
    printf("\n\n-- This program finds the nth term of fibonacci series --\n\n");
    printf("Enter the place of the fibonacci term you want to know : ");
    scanf("%d", &n);
    printf("\n\tThe %dth Fibonacci term is: %d\n", n, fibonacci(n));
    return 0;
}
int fibonacci(int n)
{
    // base case
    if (n == 0 || n == 1)
        return n;

    // recursive case
    return fibonacci(n - 1) + fibonacci(n - 2);
}                    
                

Output

-- This program finds the nth term of fibonacci series --

Enter the place of the fibonacci term you want to know : 12
 The 12th Fibonacci term is: 144