2. The given program asks the user to enter 5 integer numbers and prints the average of the numbers. The program is already written using a while loop. Try to understand each line of code and get the intuition of the while loop. You need to modify the code and use a for loop instead of a while loop to obtain the same output. You should name this project as Lab1B.
#include <iostream>
using namespace std;
int main() {
// Variable declaration
int total_num = 5, i = 0, element, sum = 0, average;
// for loop to calculate the sum
for (i = 0; i < total_num; i++) {
cin >> element;
sum = sum + element;
}
average = sum / total_num; // calculation of average
// Print out the result
cout << "The average value is: " << average << endl;
return 0;
}