Skip to content

Added fibonacci series program and updated readme file . #1

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
# [27) Program for checking given year is LEAP or NOT using if / else statement.](codes/leap_year_iff.c)
# [28) Program for finding greatest among 3 number using if / else statement.](codes/greatest_iff.c)
# [29) Program for reverse the given 3 digit number without loop.](codes/reverse.c)
# [30) Program for Checking the number whether the number is PALINDROM or NOT.](codes/palindrom.c)
# [31) Program for checking the number for armsstrong number of 3 digit without loop.](codes/armstrong_3digit.c)
# [30) Program for Checking the number whether the number is PALINDROME or NOT.](codes/palindrom.c)
# [31) Program for checking the number for Armsstrong number of 3 digit without loop.](codes/armstrong_3digit.c)
# [32) Program for printing Fibonacci Series upto given no. of digit using For loop .](codes/fibonacci_series.c)
18 changes: 18 additions & 0 deletions codes/fibonacci_series.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//The Fibonacci sequence is a sequence where the next term is the sum of the previous two terms.
//The first two terms of the Fibonacci sequence are 0 followed by 1.

#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;
}