Help fix errors in code. Follow the instructions for starting C++ and viewing the Introductory21.cpp file, which is cont

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Help fix errors in code. Follow the instructions for starting C++ and viewing the Introductory21.cpp file, which is cont

Post by answerhappygod »

Help fix errors in code.
Follow the instructions for starting C++ and viewing theIntroductory21.cpp file, which is contained in either theCpp8\Chap11\Introductory21 Project folder or the Cpp8\Chap11folder. (Depending on your C++ development tool, you may need toopen the project/solution file first.) The program should calculatethe average stock price stored in the prices array. It then shoulddisplay the average price on the screen. Complete the program usingthe for statement. Save and then run the program.
//Introductory21.cpp - Displays the average stock price
#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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply