Q:

C PROGRAM EXAMPLE FOR FIBONACCI SERIES

0

C PROGRAM EXAMPLE FOR FIBONACCI SERIES:

What is Fibonacci series?

First two numbers of the fibonacci series is 0 and 1. From 3rd number onwards, the series will be the sum of previous 2 numbers.

 

Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, etc

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main()
{
   int f1=0, f2=1, fib_ser, cnt=2, lmt;
 
   printf("Please enter the limit of the Fibonacci series :");
   scanf("%d",&lmt);
   printf("\nFibonacci series is: \n%d \n%d \n",f1,f2);
 
   while (cnt < lmt)
   {
      fib_ser=f1+f2;
      cnt++;
      printf("%d\n",fib_ser);
      f1=f2;
      f2=fib_ser;
   }
   return 0;#include <stdio.h>
int main()
{
   int f1=0, f2=1, fib_ser, cnt=2, lmt;
 
   printf("Please enter the limit of the Fibonacci series :");
   scanf("%d",&lmt);
   printf("\nFibonacci series is: \n%d \n%d \n",f1,f2);
 
   while (cnt < lmt)
   {
      fib_ser=f1+f2;
      cnt++;
      printf("%d\n",fib_ser);
      f1=f2;
      f2=fib_ser;
   }
   return 0;

OUTPUT OF C PROGRAM FOR FIBONACCI SERIES:

Please enter the limit of the Fibonacci series : 10
Fibonacci series is:
0
1
1
2
3
5
8
13
21
34

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now