Help
Dec 18th, 2000, 11:04 PM
#include <stdio.h>
int main() {
int temper[7];
int day, sum;
printf("Enter in 7 temps:\n ");
for (day=0;day<7;++day){
printf("Enter in temperature for day %d: ", day);
scanf("%d",&temper[day]);
}
sum=0;
for(day=0;day<7;++day)
sum += temper[day];
printf("Average is %d.",sum/7);
}
Okay first off,
1. in the for loop it initializes day to 0.
Day is not an array so how does it hold all seven integers?
2.in the second for loop it sets the variable day back to zero. How does it remember the temps then?
3. the sum+= temper[day]. What exactly is this function saying +=?
Thanks in advance.
:)
int main() {
int temper[7];
int day, sum;
printf("Enter in 7 temps:\n ");
for (day=0;day<7;++day){
printf("Enter in temperature for day %d: ", day);
scanf("%d",&temper[day]);
}
sum=0;
for(day=0;day<7;++day)
sum += temper[day];
printf("Average is %d.",sum/7);
}
Okay first off,
1. in the for loop it initializes day to 0.
Day is not an array so how does it hold all seven integers?
2.in the second for loop it sets the variable day back to zero. How does it remember the temps then?
3. the sum+= temper[day]. What exactly is this function saying +=?
Thanks in advance.
:)