Skip to main content
Search
Search This Blog
Livecodo
Pages
Home
Courses
Blog
About us
More…
Share
Get link
Facebook
X
Pinterest
Email
Other Apps
March 28, 2024
A Fibonacci sequence is defined as follows: the first and second terms in the sequences are 0 and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write a C program to generate the first n terms of the sequence.
#include
#include
int main() { int a,n,t1=0,t2=1,t3=t1+t2; printf("enter the number of terms:"); scanf("%d",&n); printf("fibonacci series is\n%d\n%d\n",t1,t2); for(a=3;a<=n;a++) { printf("%d\n",t3); t1=t2; t2=t3; t3=t1+t2; } return 0; }
Popular Posts
March 26, 2024
Dynamic Memory allocation in C
May 18, 2024
Searching and sorting Algorithm in C