ShriRam Changed status to publish July 15, 2022
#include<stdio.h> void main() { int n1 = 0, n2 = 1, nextTerm = 0, n; printf("Enter an Number: "); scanf("%d", &n); // displays the first two terms which is always 0 and 1 printf("Fibonacci Series: %d, %d, ", n1, n2); nextTerm = n1 + n2; while (nextTerm<= n) { printf("%d, ", nextTerm); n1 = n2; n2 = nextTerm; nextTerm = n1 + n2; } getch(); }
ShriRam Changed status to publish July 15, 2022