Created
September 19, 2017 09:11
-
-
Save adamlukes/6252c2a257c79ea5fe91b8e73762ba9c to your computer and use it in GitHub Desktop.
C Program to Display Fibonacci Sequence
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 i, n, t1 = 0, t2 = 1, nextTerm; | |
printf("Enter the number of terms: "); | |
scanf("%d", &n); | |
printf("Fibonacci Series: "); | |
for (i = 1; i <= n; ++i) | |
{ | |
printf("%d, ", t1); | |
nextTerm = t1 + t2; | |
t1 = t2; | |
t2 = nextTerm; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To follow this code tutorial,please have a basic overview of C Programming language and Top 10 Alarm clock Apps for Android.
Output of this Program will be as under:
Enter the number of terms: 10
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,