this is what i have #include <iostream> #include <iomanip> using namespace std;
ID: 2268401 • Letter: T
Question
this is what i have
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double prices[10] = {96.5, 100.5, 100.5, 100.5, 99, 99, 99, 100, 98.5, 98.9};
double total = 0.0;
double average = 0.0;
cout << fixed << setprecision(2);
cout << "Average stock price: $" << average << endl;
return 0;
} //end of main function
Follow the instructions for starting C++ and viewing the Introductory21.cpp file which is contained in either the Cpp8iChapl1 ntroductory21 Project folder or the Cpp8tChap11 folder. (Depending on your Ci+ development tool, you may need to open the project/solution file first.) The program should calculate the average stock price stored in the prices array. It then should display the average price on the screen Complete the program using the for statement. Save and then run the programExplanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int i;
double prices[10] = {96.5, 100.5, 100.5, 100.5, 99, 99, 99, 100, 98.5, 98.9};
double total = 0.0;
double average = 0.0;
for (int i = 0 ; i < sizeof(prices) ; i++) {
cout << fixed << setprecision(2);
cout << "Average stock price: $" << average << endl;
return 0;
} //end of main function
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.