0
3.8kviews
Write a program using function to print first 'n' numbers in Fibonacci series.
1 Answer
0
94views

Program:

#include <stdio.h>
#include <conio.h>
int main(){
    int n;
    int fibo(int n);

    printf("Enter a Number:");
    scanf("%d", &n);
    printf("Fibonacci Series\n0\n1\n");
    fibo(n);
    getch();
}

int fibo(int n) {
    int a=0, b=1, c, i;
    for(i=1; i<=n-2; i++)   {
        c=a+b;
        printf("%d\n", c);
        a=b;
        b=c;
    }
}

Output:

How Many Numbers: 10

0

1

1

2

3

5

8

13

21

34

Please log in to add an answer.