fibonacii

Solutions on MaxInterview for fibonacii by the best coders in the world

showing results for - "fibonacii"
Paul
02 Jun 2017
1#include<stdio.h>
2#include<conio.h>
3
4void fibonacci(int num);
5void main()
6{
7    int num = 0;
8    clrscr();
9    printf("Enter number of terms\t");
10    scanf("%d", &num);
11    fibonacci(num);
12    getch();
13}
14
15void fibonacci(int num)
16{
17   int a, b, c, i = 3;
18   a = 0;
19   b = 1;
20   if(num == 1)
21   printf("%d",a);
22
23   if(num >= 2)
24   printf("%d\t%d",a,b);
25
26   while(i <= num)
27   {
28      c = a+b;
29      printf("\t%d", c);
30      a = b;
31      b = c;
32      i++;
33   }
34}
similar questions
fibonacci