Skip to content

Commit e74e816

Browse files
raviigargthe-cybersapien
authored andcommitted
Added Fabonacci Series in C (#39)
* contributors.md file added * _ is added
1 parent 9ccd6cd commit e74e816

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

C/Misc/fabonacci.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//Header files
2+
#include <stdio.h>//header input output files
3+
#include <stdlib.h>//header library
4+
//function defination
5+
int fabonacci(int );
6+
7+
//main function
8+
9+
int main() {
10+
int N;
11+
printf("Enter the no of terms: ");
12+
scanf("%d",&N);
13+
fabonacci(N); //function call
14+
return 0;
15+
}
16+
17+
//function body
18+
19+
int fabonacci(int M) {
20+
int a=0,b=1,i,c;
21+
printf("Fabonacci series is:\n%d\n%d",a,b);
22+
//for loop to find all fabonnaci number
23+
for (i=0;i<M-2;i++) {
24+
c=a+b;//fabonacci series is addition of previous two numbers
25+
a=b;
26+
b=c;
27+
printf("\n%d",c);
28+
}
29+
return 0;
30+
}
31+

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Aditya Aggarwal (the-cybersapien)
22
Jai Kathuria (jaikathuria)
3+
Ravi Kant Garg (garg-ravi24)
34
Sumit Gupta(Invincisumit)
45
Shifali Gupta (Gupta-shifali)
56
Mohit Sharma (ms10398)

0 commit comments

Comments
 (0)