title: using multiple variables in loop using scanf
body: <p>I am a real beginner to programming. And I mean REAL beginner. My code I am trying to create is for this question: <em>Write a program that will prompt the user for 10 ages and then calculates and outputs the average of those ages.
  You should not have ten scanf statements in your program. Instead, the scanf statements should be within a loop.</em></p>
  
  <p>I have managed to get the loop running and it asks for the statements, but I don't know how to get my variable to add all the numbers inputted up at the end. Instead mine just deletes the old number in the variable and stores the new one, so when I get to the end, it says that the total was the last number entered into the input.</p>
  
  <pre><code>@autoreleasepool 
  {
      int counter;
      int ages;
  
      for (counter = 0; counter &lt; 11; counter = counter +1) 
      {
          NSLog(@"Type your age:");
          scanf("%i", &amp;ages);
      }
      NSLog(@" Average age is: %i", ages);
  }
  return 0;
  </code></pre>
  
  <p>There it is.</p>