Hi. im trying to sum even fibonacci numbers only. ie. 0 2 2 4 6 10 16 ect.. could someone indicate where i've gone wrong.
Code:#include <stdio.h> #include <stdlib.h> #include <math.h> int main (void) { int x, y; int second =0; int sum; printf("enter the fib number: "); scanf("%d", &y); for (x=0; x<=y; x++) { if (x%2 ==0 ) { sum = x+ second; second =x; x=sum; } printf("%d \n", sum); } return 0; }