search array element in c

Solutions on MaxInterview for search array element in c by the best coders in the world

showing results for - "search array element in c"
Juno
19 Jan 2017
1#include <stdio.h>
2
3int main()
4{
5    int ara[10]={1,2,3,4,5,6,7,8,9,10};
6    int i,is_found=-1,search_value;
7    printf("Enter search value:\n");
8    scanf("%d",&search_value);
9    for(i=0;i<10;i++){
10        if(ara[i]==search_value){
11            is_found=i;
12        }
13    }
14    
15    if(is_found==-1){
16        printf("Item not found\n");
17        
18    }else{
19        printf("Item found at index on. %d\n",is_found);
20    }
21
22    return 0;
23}