
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A simple c program to generate and print the fibonacci series up to a given number. The user is prompted to enter the range, and the program prints the first two values (0 and 1) followed by the rest of the series, calculated by adding the previous two numbers.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

int main(){ int k,r; long int i=0l,j=1,f; //Taking maximum numbers form user printf("Enter the number range:"); scanf("%d",&r); printf("FIBONACCI SERIES: "); printf("%ld %ld",i,j); //printing firts two values. for (k=2;k<r;k++){ f=i+j; i=j; j=f; printf(" %ld",j); } return 0 ; }