Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Fibonacci find numbers

+3 votes
asked Nov 21, 2019 by students 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

6 Answers

–1 vote
answered Nov 24, 2019 by Adil Shaik (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 RAGE MONSTER rocks (570 points)
wrong answer.

you are printing  all Fibonacci numbers up to inputted number ,
better read the question again!
commented Nov 28, 2019 by anonymous
While loop can be terminate by ; so the numbers can be displayed.
0 votes
answered Nov 24, 2019 by Rohan Ghobade (520 points)
0 votes
answered Nov 24, 2019 by Rohan Ghobade (520 points)
0 votes
answered Nov 24, 2019 by Jeff Steinborn (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
0 votes
answered Nov 24, 2019 by ASHU8084TOSH (140 points)
0 votes
answered Nov 24, 2019 by RAGE MONSTER rocks (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;
 
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...