Hi, i'm just trying to finish up this code and need some help with the parts commented out that say fill in. Thanks
int main()
{
float *monthSales; // a pointer used to point to an array
// holding monthly sales
float total = 0; // total of all sales
float average; // average of monthly sales
int numOfSales; // number of sales to be processed
int count; // loop counter
cout << fixed << showpoint << setprecision(2);
cout << "How many monthly sales will be processed? ";
cin >> numOfSales;
// Fill in the code to allocate memory for the array pointed to by
// monthSales.
if ( // Fill in the condition to determine if memory has been
// allocated (or eliminate this if construct if your instructor
// tells you it is not needed for your compiler)
)
{
cout << "Error allocating memory!\n";
return 1;
}
cout << "Enter the sales below\n";
for (count = 0; count < numOfSales; count++)
{
cout << "Sales for Month number "
<< // Fill in code to show the number of the month
<< ":";
// Fill in code to bring sales into an element of the array
}
for (count = 0; count < numOfSales; count++)
{
total = total + monthSales[count];
}
average = // Fill in code to find the average
cout << "Average Monthly sale is $" << average << endl;
// Fill in the code to deallocate memory assigned to the array.
return 0;
int main()
{
float *monthSales; // a pointer used to point to an array
// holding monthly sales
float total = 0; // total of all sales
float average; // average of monthly sales
int numOfSales; // number of sales to be processed
int count; // loop counter
cout << fixed << showpoint << setprecision(2);
cout << "How many monthly sales will be processed? ";
cin >> numOfSales;
// Fill in the code to allocate memory for the array pointed to by
// monthSales.
//Step 1.
monthSales = // Fill in missing code.//Step 2.if ( /* Fill in the condition to determine if memory has been
// allocated (or eliminate this if construct if your instructor
// tells you it is not needed for your compiler)*/)
//Step 3.// Two Things missing here.
{
cout << "Error allocating memory!\n";
return 1;
}
cout << "Enter the sales below\n";
for (count = 0; count < numOfSales; count++)
{
cout << "Sales for Month number "//Step 4.
<< // Fill in code to show the number of the month
<< ":";
//Step 5.
// Fill in code to bring sales into an element of the array
}
for (count = 0; count < numOfSales; count++)
{
total = total + monthSales[count];
}
//Step 6.
average = // Fill in code to find the average
cout << "Average Monthly sale is $" << average << endl;
//Step 7.
// Fill in the code to deallocate memory assigned to the array.
return 0;
}
My bad, disregard step 3. When I started working with the code I realized how it is working and now see that nothing is missing except the if condition.