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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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
c
Please
log in
or register to answer this question.
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.
Please
log in
or register to add a comment.
0
votes
answered
Nov 24, 2019
by
Rohan Ghobade
(
520
points)
https://onlinegdb.com/SJiQ0ow3r
Please
log in
or register to add a comment.
0
votes
answered
Nov 24, 2019
by
Rohan Ghobade
(
520
points)
https://onlinegdb.com/SyELknD2B
Please
log in
or register to add a comment.
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
Please
log in
or register to add a comment.
0
votes
answered
Nov 24, 2019
by
ASHU8084TOSH
(
140
points)
https://onlinegdb.com/BJOVY6vnS
Please
log in
or register to add a comment.
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;
}
Please
log in
or register to add a comment.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...