Showing posts with label Linear Search. Show all posts
Showing posts with label Linear Search. Show all posts
C#: Linear Searching using Arrays

C#: Linear Searching using Arrays

In this C# tutorial we are  "developing a simple program which accepts number entered by the user and displays result if it is found in a single dimensional array" . Here we are taking variable "num" for number entered by the user and "arr" for initializing our array with five elements respectively. It asks user to enter a number , if the element found then it displays message "element found!!". For this we are using for loop here. Also you see in line 11 we have taken variable flag and initialized it with 0. If element is found then flag will be updated to 1, if its not then it will remain 0 as you see in line 47. Now, lets get started!!