Question: **** Explain this program in detail. Step by step**** include using namespace std; int main() { int numStudents; float numHours, total, average; int count1 =
**** Explain this program in detail. Step by step****
include
using namespace std;
int main()
{
int numStudents;
float numHours, total, average;
int count1 = 0, count2 = 0; // these are the counters for the loops
cout << "This program will find the average number of hours a day"
<< " that each given student spent programming over a long weekend"
<< endl << endl;
cout << "How many students are there ?" << endl << endl;
cin >> numStudents;
for (count1 = 1; count1 <= numStudents; count1++)
{
total = 0;
for (count2 = 1; count2 <= 3; count2++)
{
cout << "Please enter the number of hours worked by student "
<< count1 << " on day " << count2 << "." << endl;
cin >> numHours;
total = total + numHours;
}
average = total / 3; cout << endl;
cout << "The average number of hours per day spent programming by"
<< " student " << count1 <<" is " << average
<< endl << endl << endl;
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
