Answer to Question #306809 in C for Fibnocci series c

Question #306809

Enter number to check Fibonacci are not

1
Expert's answer
2022-03-06T14:04:20-0500
#include <stdio.h>
    
int main()
{
    int num;
    int i, y, z, b;
    short fibonacci;
    y = 1;
    z = 1;
    b = 1;
    fibonacci = 0;     
    printf("Enter a Number: ");
    scanf("%d", &num);    
    for (i = 1; i < num; i++)
    {
      z = y;
      y = b;
      b = z+y;
      if (b == num)
      {
         fibonacci = 1;
         break;
      }           
    }
    if (fibonacci == 1)
       printf("Number is Fibonacci");
    else
       printf("Number is not Fibonacci");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS