C program to find given element in array

C program to find given element in array

Explanation :

So far we have seen how to take input in array and printing the same. We have got knowledge, how to scan an array ? Right… ┬áIn this post we are finding an element if it found then we have to print its position otherwise say “Element not found “. We have read the relational operators which are used to compare values.

step 0 : initialize found variable as 0 means notfound

step1: Input the array and value to be searched

Step2 : Scan the array from start position to size of array

— check for equality of array element (arr[i] ) and search value (findval) using (arr[i]==findval)

— above condition is true then initialize fount=1 and break the loop

step3 : if found==1 then print the found value and position too.

 

Code :

 

C program to find given element in array.