NPTEL Introduction to Programming in C Assignment 3 Question 1
Write a C function to find the kth occurrence of an even integer in a sequence of non-negative integers, and then call your function from main.
Your function should be according to the following declaration:
int find_even(int k);
You are given the input in two lines:
The first line contains a positive integer k. In the second line, you will be given a sequence of numbers.
You have to find the kth occurrence of n in the sequence below.
The second line consists of a sequence of non-negative integers, terminated with a -1. The -1 is not part of the sequence.
If there are k even numbers in the sequence, then output the kth occurrence of even in the sequence. Otherwise, output a -1.
Sample Input
2
1 1 3 2 3 4 1 -1
Sample Output
4
2
1 1 2 3 3 -1
-1
2
2 1 1 2 3 3 -1
2
1
1 1 2 3 3 -1
2
10
1 1 2 3 3 -1
-1