Created
December 18, 2014 06:54
-
-
Save scratchyourbrain/06223d0fc7a1acf6b4ca to your computer and use it in GitHub Desktop.
C Program to Display Fibonacci Series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int count, n, t1=0, t2=1, display=0; | |
printf("Enter number of terms: "); | |
scanf("%d",&n); | |
printf("Fibonacci Series: %d %d ", t1, t2); /* Displaying first two terms */ | |
count=2; /* count=2 because first two terms are already displayed. */ | |
while (count<n) | |
{ | |
display=t1+t2; | |
t1=t2; | |
t2=display; | |
++count; | |
printf("%d ",display); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment