Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 7.1, Problem 9STE
Explanation of Solution
Code snippet for given scenario:
/*Declaration of variables*/
int index, a[20];
/*Prompt the value for inputs*/
cout << "Enter 20 values:\n";
//Loop
for (index = 0; index < 5; index++)
//Get the value from user
cin >> a[index];
Explanation:
- Declare the variable “index” and “a[]” in type of integer.
- Prompt the user for input.
- Using “for” loop, get the array value from user...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ program that reads 6 real numbers from the user (negative and positivenumbers) into an array, then it does the following: Display all the values of array in reverse order. Find the sum and average of positive numbers of the array and display them. Count negative numbers of the array and display it. Find the minimum value of the array and display it. Find the index of the minimum value of the array and display it.
Define an array with a maximum of 20 integer values and fill the array withnumbers of your own choosing as intializers. Then write, compile, and run a C++ program that reads the numbers in the array and places all zero and positive numbers in an array named positive and all negative numbers in an array named negative. Finally, have your program display the values in both the positive and negative arrays.
Please complete this program in C++
Please enusre that there is plenty of comments. PLENTY even if unessessary.
Please include screenshots of actual code, screenshots of output, and code in the browser so I can copy and paste.
Thank you.
Chapter 7 Solutions
Problem Solving with C++ (10th Edition)
Ch. 7.1 - Prob. 1STECh. 7.1 - In the array declaration double score(5); state...Ch. 7.1 - Identity any errors in the following array...Ch. 7.1 - What is the output of the following code? char...Ch. 7.1 - What is the output of the following code? double a...Ch. 7.1 - What is the output of the following code? int i,...Ch. 7.1 - Prob. 7STECh. 7.1 - Suppose we expect the elements of the array a to...Ch. 7.1 - Prob. 9STECh. 7.1 - Suppose you have the following array declaration...
Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...
Knowledge Booster
Similar questions
- Please complete this program in C++ Please enusre that there is plenty of comments. PLENTY even if unessessary. Please include screenshots of actual code, screenshots of output, and code in the browser so I can copy and paste. Thank you.arrow_forwardTrying to colve this arrays assingment, the programming language is c++ could you help? Thanks!arrow_forwardI have an array with names. Sometimes the same name can appear more than once. In C++ how do I write a function that prints the duplicates once?arrow_forward
- 8. using c++, Write a function method that determines the mean of all the values in an array of integers. Your mean function should call a separate function that you write that determines the sum. Don’t use built-in sum or mean gadgets, but roll your own.arrow_forwardWrite a C++ program which takes input from user and stores it in an array. Afterwards, ittakes another number input from the user and searches it in the array. If number found,displays “Number Found”, else prints “Number not found”.arrow_forwardI have an array with names. The string array sometimes has duplicates names. In c++ is there a way to read the array and move only one of each name into a new array with no duplicates? With the libraries iostream, iomanip, f stream, and namespace stdarrow_forward
- Write a C++ program that helps the user plan out their budget. It should ask the user for the most recent 5 things that they bought; it should ask for both the name for the item and its price. Then, print out the following: total money spent, average money spent per item, lowest priced item, and highest priced item. You can assume that each item has a different name and a different price. You must use at least 1 array and you must display all numbers as dollar values (exactly 2 places after the decimal) EXPECTED OUTPUT Welcome to the Budget Helper. What are the last 5 things you bought? Item 1 name: Bananas Item 1 price: 1.5 Item 2 name: Shoes Item 2 price: 45 Item 3 name: Coffee Item 3 price: 2.5 Item 4 name: Metrocard Item 4 price: 120 Item 5 name: Jacket Item 5 price: 89 The total amount you spent is $258The average price per item is $51.60The cheapest item is BananasThe most expensive item is Jacketarrow_forwardTake 10 integer inputs from user and store them in an array. Again ask user to give a number. Now, tell user whether that number is present in array or not. (Did this in C++ programming)arrow_forwardCODE USING C++ 2. Now, Please Show Me by CodeChum Admin Thanks for fixing me! I am now okay. My next problem though is I don't know what to do with my life. Can you please show me? Instructions: In the code editor, you are provided with an array called me that contains 100 elements. Your task is to print all the elements of the array starting from the last element up to the first element. For this problem, using a loop would be very helpful. Output 7 18 19 17 15 14 15 98 12 22 4 91 19 17 10 7 77 13 4 33 2 18 69 17 78 14 15 22 12 34 101 69 19 89 16 14 22 13 2 99 44 18 . . .arrow_forward
- Write a program in c++ You have 12 temperatures in your array. You want to calculate the average and determine the results that are greater than or equal to that average.arrow_forwardWrite a C++ program that reads 6 real numbers from the user (negative and positive numbers) into an array, then it does the following:a. Find the sum and average of positive numbers of the array and display them. b. Count negative numbers of the array and display it.c. Find the minimum value of the array and display it.d. Find the index of the minimum value of the array and display it.arrow_forwardCreate an array with the size of the sum of the digits in your student number using the C language. This array will be filled by taking values from the user respectively. From the values entered from the keyboard, those that are divisible by 3 will be added from the beginning of the array, and those that are not divisible will be added from the end of the array. After the array is completely filled, print the final version on the screen (Note: Same answers (copied answers) will not be considered.) My student number = 1910213570arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education