title: How to find the maximum value in an array of structures?
body: <p>How to get the max value in a structure? I have tried to create a simple program but I'm having issues with the <code>if</code> statement or variable, since I cannot determine the winner or candidate number which has the highest score.</p>
  
  <pre><code>#include&lt;stdio.h&gt; 
  #include&lt;conio.h&gt; 
  
  struct Candidate{ 
  float Score; 
  short Number; 
  }candidate1[5]; 
  
  main(){ 
  
  int i,n,highest; 
  for(i=0;i&lt;5;i++){ 
  
  printf("Candidate Number: "); 
  scanf("%i",&amp;candidate1[i].Number); 
  printf("Score: "); 
  scanf("%i",&amp;candidate1[i].Score); 
  
  highest=candidate1[i].Score;    
  
  for (n=0;n&lt;5;n++) 
  
  if (candidate1[i].Score&gt;highest); 
  } 
  printf("Highest Number: %i\n",highest); 
  
  system("pause");    
  
  }
  </code></pre>