Question
Introduction to Programming with C++ (3rd Edition) Chapter 11, Problem 1PE (Analyze input) Write a program that first reads an integer for the array size,
Introduction to Programming with C++ (3rd Edition)
Chapter 11, Problem 1PE
(Analyze input) Write a program that first reads an integer for the array size, then reads numbers into the array, computes their average, and finds out how many numbers are above the average.
answer is not building correctly. Please help
int Prog11_1() { // Declare the variables int i,j,arraySize,sum=0,count=0,value; double average=0; // Declare the pointer variable int *numbers;
// Read the size of an array cout << "Enter array size: "; cin >> arraySize;
numbers = new int[arraySize];
cout << "Enter integer values : "; for (i = 0; i < arraySize; i++) { // Read and store numbers in an array cin >> value; *(numbers + i) = value; sum=sum+value; } // Calculate the average of the numbers average = sum/arraySize; cout << "Average number is: " ;
cout << "Above average numbers are: " <
for (j = 0; j < arraySize; j++) { if(*(numbers + j)>average) { cout<<*(numbers + j)<< " "; count++; } cout<<"Total of above average number is " < }
// Pause the system system("pause"); // Return the value return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started