title: Finding min and max values
body: <p>I am trying to write a simple program that reads integers from a data file and outputs the minimum and maximum value. The first integer of the input file will indicate how many more integers will be read, and then the integers will be listed.</p>
  
  <p>My program compiles without any problem, however, it returns values that are not part of the set in my test data file. Could anyone help with diagnose this issue? </p>
  
  <pre><code>int main(){
  FILE *fp = fopen("data.txt", "r");
  int count;
  int num;
  int i;
  int min = 0;
  int max = 0;
  
  fscanf (fp, "%d", &amp;count);
  
  for (i = 0; i &lt; count; i++)
      fscanf( fp, "%d", &amp;i);  
      {   
      if (num &lt; min)
          min = num;
      if (num &gt; max)
          max = num;
      }
  fclose (fp);
  
  printf("Of the %d integers, the minimum value is %d and the maximum value is %d \n", count, min, max);} 
  </code></pre>