Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace LinearSearchProper
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
- int index = -1;
- int i = 0;
- Console.WriteLine("Please enter your search term:");
- int searchterm = Convert.ToInt32(Console.ReadLine());
- for (i = 0; i <= a.Length - 1; i++)
- {
- if (a[i] == searchterm)
- {
- index = i;
- break;
- }
- }
- Console.WriteLine("Item was found at: " + index);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement