I/ This program finds the average time spent programming by a student // each day over a three-day period. #include using namespace std; int main() { int numStudents; float numHours, total, average;...


Topic: Nested for-loop


Question: Which part of the code you need to alter so that the inner loops iterates n times, where n is a positive integer input by the user. In other words, let the user decide how many days to consider just as the choose how many students to consider.


I/ This program finds the average time spent programming by a student //<br>each day over a three-day period.<br>#include <iostream><br>using namespace std;<br>int main()<br>{<br>int numStudents;<br>float numHours, total, average; int student, day<br>Il these are the counters for the loops<br>VERI<br>cout << > numStudents; for(student = 1; student <= numstudents;="" student++)="" {="" total="0;" for(day="1;" day=""><= 3;="" day++)="" {="" cout="">< "please="" enter="" the="" number="" of="" hours="" "=""><"worked by="" student="" "="" danal="" "/="">
Extracted text: I/ This program finds the average time spent programming by a student // each day over a three-day period. #include using namespace std; int main() { int numStudents; float numHours, total, average; int student, day Il these are the counters for the loops VERI cout < "this="" program="" will="" find="" the="" average="" number="" of="" om=""><" hours="" a="" day="" that="" a="" student="" spent="" programming"=""><" over="" a="" long="" weekend\n\n";="" cout="">< "how="" many="" students="" are="" there?="" ";="" cin="">> numStudents; for(student = 1; student <= numstudents;="" student++)="" {="" total="0;" for(day="1;" day=""><= 3;="" day++)="" {="" cout="">< "please="" enter="" the="" number="" of="" hours="" "=""><"worked by="" student="" "="">
stdent ee

Extracted text: stdent ee" cn day ch -nmaurs total = total + nomHours J end or inner loop average = total/s cout e ena; cout ee "The average number of hours per eday spent programming by e "student" ee student e "ise verage e endi eeenai eeena Jwend of outer loop retum Samplo Run: UM This program will ind the averago number of hours a day that a studart apant programming over a long weekend How many students are there? 2 Please enter the number of hours worked by student 1 an day 1 Ploaso entor tho number of hours worked by studen: 1 cn day 3 5 The average number of hours per day spent programming by stulent 1 is 5 OMNIA Please enser the number of hours worked by sudent 2 an day 1 9 Please enter the nurmber of hours worked by studen! 2 cn day 2 13 Please enter the number of hours worked by student 1 on day 3 6 The averaga number of hours per day spent programming by studant 2 is9 QUestione Note that the inner loop of this program is always executed exactly three limes- once for each day of the long weskend. Which part of the code you need to alter so that the Inner loop ierates n times, where nis a posive integer inçut by the user, In other words, let the user decide haow many days to consider justastheychoose how many students to oansider. MIN
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here