#include<stdio.h> #include<conio.h> void main() { int n,i; long f0=0,f1=1,f2; clrscr(); printf("\n enter n\n"); scanf("%d", &n); printf("\n Fibonacci series up to %d terms \n", n); for(i=1; i<=n; ++i) { printf("%10d",f0); /* printing the terms with considering 10 digit number, which gives proper gap between each terms */ f2=f0+f1; /* finding the next term */ f0=f1; /* exchanging the terms to get next term of the sequence */ f1=f2; } getch(); } Output 1: Enter n 5 Fibonacci series up to 5 terms 0 1 1 2 3 Output 2: Enter n 10 Fibonacci series up to 10 terms 0 1 1 2 3 5 8 13 21 34