Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone explain this C++ code to me please? #include <iostream> using namesp

ID: 2988727 • Letter: C

Question

Can someone explain this C++ code to me please?

#include <iostream>

using namespace std;

int main ()
{
  
double miles [10] = {240.5, 300, 189.6, 310.6, 280.7, 216.9, 199.4, 160.3, 177.4, 192.3};
double gallons [10] = {10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, 8.4};
double mpg [10];
  
double * milesPtr;
milesPtr = miles;
double * gallonsPtr;
gallonsPtr = gallons;
for (int i = 0; i < 10; i++)
{
mpg[i] = milesPtr[i]/gallonsPtr[i];
  
}
for (int i = 0; i < 10; i++)
{
cout << mpg[i] << endl;
}
  
  

Explanation / Answer

it is calculating miles per gallon

tthe for loop calculates this and stores in mpg array