what is the problem with my code, it is not returning value if b!=-1
#include <stdio.h>
int find_even(int k){
int a,b,i=0;
scanf("%d",&a);
while (a>=0){
if(i<k){
if (a>=0 && a%2 == 0){
b=a;
i++;
}
}
scanf("%d",&a);
}
if (i<k){
b=-1;
}
return b;
}
void main(){
int k;
printf("Enter the value of K : ");
scanf("%d",&k);
printf("Enter the sequence of non negative integers and at end enter a negative integer : ");
if (find_even(k)<0)
printf("No %dth even integer exist.",k);
else
printf("Result = %d. ",find_even(k));
}
I am trying to get the kth even digit but I am not getting any value returned whenever the value of b isn't equal to -1