title: How can I break the loop and exclude the last input in C#?
body: <p>I have to write a code that asks the user how many movies will be entered. After entering the number of movies, the user should be asked for the names of the movies. All names will be added to the array <code>movies</code>. If the user enters "Exit", the program should stop and display the movies that the user has already entered.</p>
  
  <p>I wrote this code:</p>
  
  <pre><code>Console.WriteLine("Enter number of movies:");
  int num1 = int.Parse(Console.ReadLine());
  string[] movies = new string[num1];
  
  for (i = 0; i &lt; num1; i++)
  {
      Console.WriteLine("Enter movie name:");
      movies[i] = Console.ReadLine();
      if(movies[i] == "Exit" || movies[i] == "exit")
      {
          break;
      }
  }
  for (i = 0; i &lt; num1; i++)
  {
      Console.WriteLine("Movie {0} is {1}", i + 1, movies[i]);
  }
  </code></pre>
  
  <p>The problem is: If user writes <code>exit</code> the program shows <code>exit</code> as a movie. For example: User wants to enter 4 movies and enters <code>first</code> as the first movies and <code>exit</code> as the second movies. The output of the program in this case will be as follows:</p>
  
  <pre><code>movie 1 is first 
  movie 2 is exit
  movie 3 is
  movie 4 is
  </code></pre>
  
  <p>But the program should only display the first movie that was entered. What am I doing wrong?</p>