Question
Array Using Cpp Syntax Write a short program that prompts the user and reads in integers into an array called Table. When the user enters
Array Using Cpp Syntax
Write a short program that prompts the user and reads in integers into an array called Table. When the user enters a negative number, the input stops. Keep track of how many numbers were read in (at least 5 and no more than 10; what size should you declare the array to have?)
Then add code to do the following:
- Print how many numbers were read in, and then print out all the numbers that were stored in the array.
- Find and print the average. Then find and print how many of the numbers are less than the average calculated above, how many are exactly the same value as the average, and how many were greater than the average. Test and make sure it works.
- Ask the user for a value and see if it is in the array. If found, the program should print Found at followed by the index where the value was found. Ask the user whether to repeat and keep repeating if the user wants to. (What kind of a loop statement would be good? The body of the loop would be:
Asking user for a value and reading it in.
Searching for the value in the array and printing either Not found. or Found at index .. Asking user whether to continue and reading in the answer.)
Test using different values. At a minimum, test using the following values:
1) value not in the array.
2) the first value of the array,
3) the last value in the array
4) value in the array somewhere between the first and the last values.
4. Find and print the smallest value in the array AND the index where it is located. Then write code that will swap the smallest value and the first value in the array.
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