
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410 تمرين 10
Accumulating Totals in a Loop
const int DAYS_IN_WEEK = 7;for(counter = 1; counter = DAYS_IN_WEEK; counter++){cout ? "Enter rainfall amount for Day " + counter ? ": ";cin rainfall;cout ? "Day " ? counter ? "rainfall amount is " ?rainfall ? " inches" ? endl;sum += rainfall;}// calculate averageaverage = sum / DAYS_IN_WEEK;
What happens when you compile this program if the variable sum is not initialized with the value 0?
const int DAYS_IN_WEEK = 7;for(counter = 1; counter = DAYS_IN_WEEK; counter++){cout ? "Enter rainfall amount for Day " + counter ? ": ";cin rainfall;cout ? "Day " ? counter ? "rainfall amount is " ?rainfall ? " inches" ? endl;sum += rainfall;}// calculate averageaverage = sum / DAYS_IN_WEEK;
What happens when you compile this program if the variable sum is not initialized with the value 0?
التوضيح
Variable is not initialized with value 0...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
لماذا لم يعجبك هذا التمرين؟
أخرى 8 أحرف كحد أدنى و 255 حرفاً كحد أقصى
حرف 255