C Program to Display Fibonacci Sequence
Problem Statement:
The Fibonacci sequence is a sequence where the next term is the sum of the previous two terms.
PROGRAM:
#include<stdio.h>
int main()
{
int i,n,a=0,b=1,c;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf(" %d",a);
}
return 0;
}
OUTPUT:
8
1 1 2 3 5 8 13 21
No comments:
Post a Comment