title: Defining boolean local variables
body: <p>Note: This is my first time using "Stack Overflow" and I am relatively new to C# </p>
  
  <p>(please excuse my poor programming skills at the moment)</p>
  
  <p>My Code:</p>
  
  <pre><code>static void Main(string[] args)
      {
          Challenge(5, 12);
      }
      static void Challenge(int num1, int num2)
      {
          //finds the sum of the two variables
          int sum = num1 + num2;
          Console.WriteLine("The sum of {0} and {1} is...\n{2}", num1, num2, sum);
  
          bool isDivisible = true;
          //checks if divisible by 5 and sets a value for 'isDivisible'
          if ((sum % 10 == 5) || (sum % 10 == 0))
          {
              Console.WriteLine("\nThe sum is divisible by 5!");
              isDivisible = true;
          }
          else if ((sum % 10 != 5) || (sum % 10 != 0))
          {
              Console.WriteLine("\nThe sum is not divisible by 5!");
              isDivisible = false;
          }
  
          //depending on value of 'isDivisible', returns certain functions
          if (isDivisible == true)
          {
              Console.WriteLine("This value is usable.");
              Console.WriteLine("\n\nThe remaining usable values are: ");
  
              for (int newVal = sum + 1; newVal &lt;= 55; newVal++) // '+ 1' added to make sure 'sum' is not printed again
              {
                  if ((newVal % 10 == 5) || (newVal % 10 == 0))
                  {
                      Console.WriteLine(newVal);
                  }
              }
          }
          else if (isDivisible == false)
          {
              Console.WriteLine("This value is not usable.");
              Console.WriteLine("\n\nThese values are considered usable: ");
  
              for (int newVal = 0; newVal &lt;= 55; newVal++)
              {
                  if ((newVal % 10 == 5) || (newVal % 10 == 0))
                  {
                      Console.WriteLine(newVal);
                  }
              }
          }
          Console.ReadLine();
      }
  </code></pre>
  
  <p>I viewed some articles online, as well as the "Stack Overflow" post: <a href="https://stackoverflow.com/questions/9233000/why-compile-error-use-of-unassigned-local-variable">Why compile error &quot;Use of unassigned local variable&quot;?</a> . After learning that local variables are not initialized (and must be given a value), I set my bool value for "isDivisible" equal to true by default. </p>
  
  <p>Question:</p>
  
  <p>Is there a better way to define a local variable that is of Boolean value (at least in the case of the program I am trying to run here)?</p>
  
  <p>Thanks!</p>