title: Linear Search Problem
body: <p>My program has no compile errors but the output is incorrect. Example input:</p>
  
  <p>size of array: 5<br>
  input numbers: 5 4 3 2 1<br>
  //sorted: 1 2 3 4 5<br>
  search: 1<br>
  output: number 1 found at index 4</p>
  
  <p>the output should be number 1 found at index 0 since the numbers were sorted already. How will I change it to this.</p>
  
  <pre><code>    int[] nums = new int[100];
      int SizeNum;
      bool isNum = false;
  
      private void ExeButton_Click(object sender, EventArgs e)
      {
          int i, loc, key;
          Boolean found = false;
          string SizeString = SizeTextBox.Text;
          isNum = Int32.TryParse(SizeString, out SizeNum);
          string[] numsInString = EntNum.Text.Split(' ');   //split values in textbox
          for (int j = 0; j &lt; numsInString.Length; j++)
          {
              nums[j] = int.Parse(numsInString[j]);
          }
          if (SizeNum == numsInString.Length)
          {
              Array.Sort(numsInString);
              key = int.Parse(SearchTextBox.Text);
              ResultText.AppendText("Sorted: ");
              for (i = 0; i &lt; SizeNum; i++)
                  ResultText.AppendText(" " + numsInString[i]);
                   ResultText.AppendText("\n\n");
              {
                  for (loc = 0; loc &lt; SizeNum; loc++)
                  {
                      if (nums[loc] == key)
                      {
                          found = true;
                          break;
                      }
                  }
                  if (found == true)
                      ResultText.AppendText("Number " + key + " Found At Index [" + loc + "]\n\n");
                  else
                      ResultText.AppendText("Number " + key + " Not Found!\n\n");
              }
          }
      }
  </code></pre>