P055.c (974B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* WAP to print n terms of Fibbonacci Series (Starting from term 0) */ 8 9 // This code has not been compiled. 10 // If you find any issues, please create a new issue on GitHub regarding them. 11 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 12 13 #include <stdio.h> 14 15 void printFibonacci(int); 16 17 void printFibonacci(int n) 18 { 19 int val1 = 0, val2 = 1, val3, i; 20 printf("\nFibonacci series upto %d terms :", n); 21 if (n < 0) 22 printf(" N/A"); 23 if (n == 0) 24 printf(" %d", val1); 25 if (n > 0) 26 printf(" %d %d", val1, val2); 27 for (i = 2; i <= n; i++) 28 { 29 val3 = val1 + val2; 30 printf(" %d", val3); 31 val1 = val2; 32 val2 = val3; 33 } 34 } 35 36 int main() 37 { 38 int n; 39 printf("Enter the n : "); 40 scanf("%d", &n); 41 printFibonacci(n); 42 return 0; 43 }