New Posts  All Forums:Forum Nav:

c++ help needed

post #1 of 2
Thread Starter 
I need to write a program that use a loop to add the total sum of ten given numbers in an array. It also must separately calcualte the average of the ten numbers entered by the user. I'm having difficulty creating the loop to add the ten numbers. I assume once i figure that out i can just divide the sum by 20 to get the average. So, can anyone give me some pointers on how to add numbers in an array using a loop?
post #2 of 2
int array[10], sum = 0, avg = 0;
for (int i = 0; i < 10; i++) {
sum += array[i];
avg = sum / 10;
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming