title: How to find position of an element in array (C programming)
body: <p>I have a function that asks the user to input 10 integers into an array then finds the max value of the array.</p>
  
  <pre><code>int largestPos(int array[], int size, int index) {
  
  int k, maxVal = 0;
  
  printf("Enter a starting index: ");
  scanf("%d", &amp;index);
  
  for (k = index; k &lt; size; k++){
      if (maxVal &lt; array[k]){
          maxVal = array[k];
      }
  }
  printf("The maximum value is %d at position %d \n", maxVal, array[maxVal]);
  
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>The max value calculates correct. But when I try to find the position of the max value, I get a crazy number. What is wrong with the way I am finding the position of the max value?</p>