File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change 1
1
Aditya Aggarwal (the-cybersapien)
2
2
Jai Kathuria (jaikathuria)
3
+ Ravi Kant Garg (garg-ravi24)
3
4
Sumit Gupta(Invincisumit)
4
5
Shifali Gupta (Gupta-shifali)
5
6
Mohit Sharma (ms10398)
You can’t perform that action at this time.
0 commit comments