title: Having function choose largest number of given ones
body: <p>Computer gives me wrong result when choosing the largest number of three given numbers.
  I'm not sure if this is possible way to code this program. I'm new to C, but when we learned about Pascal in school, this is roughly how we made the program choose the largest number (by introducing another variable, in my case X).
  Sorry if this was posted before, can't seem to find it.</p>
  
  <pre><code>int max(int num1, int num2, int num3)
  {
      int result;
      int X;
      if (num1&gt;num2) {
          num1 = X;
      } else {
          num2 = X;
      }
      if (num3&gt;X) {
          num3 = result;
      } else {
          X = result;
      }
  
      return result;
  }
  
  int main()
  {
      printf("Result: %d", max(4, 10, 15));
      return 0;
  }
  </code></pre>
  
  <p>I'd expect it to show me MAX number of 15, but it shows me some random, big number.
  NOTE: I'm also having problems with code format</p>