4. 5 #include 6 #include 7 using namespace std; 8 9 int main() 10 { 11 int day 0; 12 13 14 15 16 17 { int totalTexts = 0; int dailyTexts 0; double average = 0.0; %3! %3D for (day = 1; day < 8; day += 1) %3! 18 19 20 21 22 cout << "How many text messages did you send on day <« day << "? "; cin >> dailyTexts; totalTexts += dailyTexts; } //end for maldo 23 24 average = static_cast(totalTexts) / (day - 1); cout <« fixed << setprecision(0); 26 cout « endl << "You sent approximately " <« average << 25 %3D 27 %3D text messages per day." « endl; return 0; 29 } //end of main function 28 Figure 7-38 wo QUESTIONS 0n n Code for Lab 7-1 1. What is the name of the program's counter variable? What is the name of its accumulator variable? 2. What is another way of phrasing the for clause's condition argument? 3. Why is the for statement's counter variable declared at the beginning of the program (in Line 11) rather than in the for clause? Would the program work correctly if the variable was declared in the for clause?
4. 5 #include 6 #include 7 using namespace std; 8 9 int main() 10 { 11 int day 0; 12 13 14 15 16 17 { int totalTexts = 0; int dailyTexts 0; double average = 0.0; %3! %3D for (day = 1; day < 8; day += 1) %3! 18 19 20 21 22 cout << "How many text messages did you send on day <« day << "? "; cin >> dailyTexts; totalTexts += dailyTexts; } //end for maldo 23 24 average = static_cast(totalTexts) / (day - 1); cout <« fixed << setprecision(0); 26 cout « endl << "You sent approximately " <« average << 25 %3D 27 %3D text messages per day." « endl; return 0; 29 } //end of main function 28 Figure 7-38 wo QUESTIONS 0n n Code for Lab 7-1 1. What is the name of the program's counter variable? What is the name of its accumulator variable? 2. What is another way of phrasing the for clause's condition argument? 3. Why is the for statement's counter variable declared at the beginning of the program (in Line 11) rather than in the for clause? Would the program work correctly if the variable was declared in the for clause?
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 20RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage