Computer Science, asked by Ashimayadav1430, 11 months ago

Write a function to print the Fibonacci Series upto input limit

Answers

Answered by mohishkhan9996
0

Answer:

hey.... mate ur ans... is here

Python Examples. Check if a Number is Positive, Negative or 0. Check if a Number is Odd or Even. Check Leap Year. Find the Largest Among Three Numbers. Check Prime Number. Display the multiplication Table.

plzz mark as brainlist....Xd

Answered by ridhimakh1219
1

Write a function to print the Fibonacci Series upto input limit

Explanation:

C program to print first Fibonacci numbers upto n terms  

#include <stdio.h>  

  // Function to print first n Fibonacci Numbers  

void fibonacci(int n)  

{  

   int f1 = 0, f2 = 1, i;  

   if (n < 1)  

       return;  

   for (i = 1; i <= n; i++)  

   {  

       printf("%d ", f2);  

       int next = f1 + f2;  

       f1 = f2;  

       f2 = next;  

   }  

}  

int main()  

{  

   int n;

   printf("Enter the number of terms: ");

   scanf("%d", &n);

   fibonacci(n);  

   return 0;  

}

Output

Enter the number of terms: 10

1 1 2 3 5 8 13 21 34 55                                                                                                                    

Similar questions