File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include<stdio.h>
2
+ void main()
3
+ {
4
+ int i;//loop counter
5
+ int n;//max value
6
+ int t1=1;//First term
7
+ int t2=1;//Second term
8
+ int nextTerm;//Next term
9
+ int sum=0;//Summation of total even Fibonacci number
10
+ int count=0;//counter to count the number of even Fibonacci numbers
11
+ printf("Enter the max value up to which you want to print the values: ");
12
+ scanf("%d",&n);
13
+ printf("The listed even Fibonacci number are: ");
14
+ printf("\nSlno.\t\tFibonacci number");
15
+ for(i=1;i<=n;i++)
16
+ {
17
+ if(t1>=1 && t1<=n)
18
+ {
19
+ nextTerm=t1+t2;
20
+ t1=t2;
21
+ t2=nextTerm;
22
+
23
+ if(t1%2==0 && t1<=n)
24
+ {
25
+ sum=sum+t1;
26
+ count++;
27
+ printf("\n %d\t\t\t%d",count,t1);
28
+ }
29
+ }
30
+
31
+ }
32
+ printf("\n\nThe required sum of the total even Fibonacci number is: %u\n\n\n",sum);
33
+
34
+ }
You can’t perform that action at this time.
0 commit comments