I am running into a bit of a confusion about one line in this code:
const int maxNum = 4;
int count = 1;
double num;
double total = 0;
double average;
while(count <= maxNum) {
cout << "please enter a number: " << endl;
cin >> num;
total = total + num;
cout << "The total is now: " << total << endl;
count++;
}
cout << "total of 4 digits is: " << total << endl;
//count--;
average = total/count;
cout << "the average of 4 digits is: " << average << "." << endl;
My question is in regards to count--;
:
With count--;
the average (double) has a decimal point.
But when I remove that line of code, the average is shown as only a integer.
What is the significance of this line?