Fibonacci Series – C Program

Fibonacci series is a sequence of numbers in which next number in the sequence is obtained by adding previous two numbers.

Source Code

#include<stdio.h>

//Fibonacci Series - FScOnline.info

int main()
{
    int first=0,second=1,next,i,n;
 
    printf("Enter how many elements: ");
    scanf("%d",&n);
    printf("\n%d %d",first,second);
 
    for(i=2;i<n;++i)
    {
        next=first+second;
        printf(" %d",next);
        first=second;
        second=next;
    }
    
    return 0;
}

 Output

fibonacci-series-c-program

Categories: C Language,C Programs,Computer Science

Tags: ,

1 Comment

  1. i confuse in this program ……how its output is 1???? and % ye kis chiz k liye use ho rha???????

    int i,j,k;
    i=10;
    j=3;
    k=i%j;
    printf(“%d”,z);

    Reply

Leave A Reply

Your email address will not be published.

×