Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C programming: In mathematics, the Fibonacci numbers (in this case only posit

ID: 3733606 • Letter: I

Question

In C programming:

In mathematics, the Fibonacci numbers (in this case only positive numbers) are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:

Write a function called fibonacci that takes two integers arguments and prints out in ascending order all fibonacci numbers between the first (or closest higher or equal) and the second argument (closest lower or equal). Your function must return the amount of fibonacci numbers printed out.

Example 1:

When the input is:

The output is

The function must return 5.

Example 2:

When the input is:

The output is

The function must return 7.

Requirements

Read the inputs from the user

Declare the prototype of your function before the main function

Call your function to do the printing based on the inputs from the user

Print a space after each number including the last one printed

#include <stdio.h>

int main() {

return 0;
}

Explanation / Answer

#include <stdio.h>

int main()
{
printf("enter the 2 numbers ");
int start,end;
scanf("%d %d",&start,&end);
printf(" no of fibonocci are:%d ",fibonocci(start,end));
return 0;
}
int fibonocci(int start,int end)
{
int a=0,b=1,count=0;
for(int sum=0;sum<end;)
{ sum=a+b;
a=b;
b=sum;
  
if(sum>=start && sum<=end)
{ count++;
printf("%d ",sum);
}
  
}

return count;
}