Intro To Sort

#codeifyoucansolve
There will be three lines of input:

V – the value that has to be searched.
n – the size of the array.
ar – n numbers that make up the array.

Output Format
Output the index of V in the array.

{The next section describes the constraints and ranges of the input. You should check this section to know the range of the input. }

Constraints
1<=n<=1000
-1000 <=x <= 1000 , x ∈ ar

{This “sample” shows the first input test case. It is often useful to go through the sample to understand a challenge. }

Sample Input

4
6
1 4 5 7 9 12

Sample Output

1

Explanation
V = 4. The value 4 is located at the 1st index in the array, so the answer is 1.

Copyright (c) 2015 HackerRank.
All Rights Reserved
Suggest Edits
14166 hackers have submitted code

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int N,K,V_arr,i;
    scanf("%d",&K);
    scanf("%d",&N);
    i=0;
    while(i<N)
        {
        scanf("%d",&V_arr);
        if(V_arr==K)
            printf("%d\n",i);
        i++;
    }
    return 0;
}

https://twitter.com/codeifucansolve