# Fibonacci find numbers

asked Nov 21, 2019 1 flag
Write a C program which calculates the smallest Fibonacci number that is greater than a given input, n. Fibonacci Series:

1 1 2 3 5 8 13 21 34 55 89 144 233 377 …

e.g. Input: 35 Input: 12

Output: 55 Output:13

–1 vote
answered Nov 24, 2019 by (120 points)
#include <stdio.h>

int main ()
{
int n, a = 0, b = 1, c = 0, i = 1;
printf ("Enter the value of n \n");
scanf ("%d", &n);
while (i <= n)
{
a = b;
b = c;
c = a + b;
i++;
printf ("%d \n", c);
}
return 0;
}
commented Nov 24, 2019 by (570 points)

you are printing  all Fibonacci numbers up to inputted number ,
commented Nov 28, 2019 by anonymous
While loop can be terminate by ; so the numbers can be displayed.
answered Nov 24, 2019 by (520 points)
answered Nov 24, 2019 by (520 points)
answered Nov 24, 2019 by (180 points)
This program takes input from the command line and finds the next fibonacci number in the series for each argument.

https://onlinegdb.com/Hy0Nl3v2r
answered Nov 24, 2019 by (140 points)
answered Nov 24, 2019 by (570 points)
#include <stdio.h>

int main()
{
int fab=1,n,one=1,two=1;
printf("enter a number  :  ");
scanf("%d",&n);
while(fab<=n)
{
fab=one+two;
one=two;
two=fab;
}
printf("smallest fabbonacci greater than %d  :  %d",n,fab);
return 0;

}