Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7.3, Problem 17STE
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that reads in ten numbers and displays the number of distinct numbers and
the distinct numbers separated by exactly one space (i.e., if a number appears multiple times,
it is displayed only once). (Hint:Read a number and store it to an array if it is new. If the number
is already in the array, ignore it. While solving the question please use an array.) After the
input, the array contains the distinct numbers. Here is the sample run of the program:
Enter ten numbers: 1 2 3 21634 5 2
The number of distinct number is 6.
The distinct numbers are: 123645
Write a program that will read up to ten letters into an array and write the letters back to the screen in the reverse order. For example, if the input is abcd. then the output should be dcba Use a period as a sentinel value to mark the end of the input. Call the array letterBox. For this exercise you need not use any functions. This is just a toy program and can be very minimal.
Write a program for the following information: Year has 365 days. You create array for temperature of each day in a year. Assign random temp values range of 30-110. Using a function Search in the array do you have 100 degree and what days. Print how many days and what days. Also print the Temp array in nice format in a function. Sample output
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
1.1 List 10 uses. for surveying in areas other than land
sunreying-
Elementary Surveying: An Introduction To Geomatics (15th Edition)
In the text, JUMP instructions were expressed by identifying the destination explicitly by stating the name (or...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What populates the Smalltalk world?
Concepts Of Programming Languages
For the circuit shown, use the node-voltage method to find v1, v2, and i1.
How much power is delivered to the c...
Electric Circuits. (11th Edition)
In Exercises 41 through 46, identify the errors. Dima,b,c,dAsDoublea=2b=3c=d=4Istoutput.Items.Add(5((a+b)/(c+d)
Introduction To Programming Using Visual Basic (11th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Multiple Frequencies. In the last assignment, we calculated the frequency ofa coin flip. This required us to have two separate variables, which we used to record the numberof heads and tails. Now that we know about arrays, we can track the frequency of all numbers ina randomly generated sequence.For this program, you will ask the user to provide a range of values (from 1 to that number,inclusive) and how long of a number sequence you want to generate using that number range.You will then generate and save the sequence in an array. After that, you will count the numberof times each number occurs in the sequence, and print the frequency of each number.Hints: You can use multiple arrays for this assignment. One array should hold thenumber sequence, and another could keep track of the frequencies of each number.Sample Output #1:What’s the highest number you want to generate?: 5How long of a number sequence do you want to generate?: 10Okay, we’ll generate 10 number(s) ranging from 1 to 5!1,…arrow_forwardWrite a program that creates array of 10 integers. Ask the user to enter the data in the array. Each time the data entered in the array should be unique. Your program should not allow the user to enter the duplicate values in the array. After feeding data into the array created, create another array of the 10 integers and save the data of 1st array in the reverse order into the second array. For Example Array 1 1 2 3 4 5 6 7 8 9 10 Array 2 10 9 8 7 6 5 4 3 2 1arrow_forwardYou’re writing a function that accepts an array of unsorted integers and returns the length of the longest consecutive sequence among them. The sequence is formed by integers that increase by 1. For example, in the array: [10, 5, 12, 3, 55, 30, 4, 11, 2] the longest consecutive sequence is 2-3-4-5. These four integers form an increasing sequence because each integer is one greater than the previous one. While there’s also a sequence of 10-11-12, it’s only a sequence of three integers. In this case, the function should return 4, since that’s the length of the longest consecutive sequence that can be formed from this array. One more example: [19, 13, 15, 12, 18, 14, 17, 11] This array’s longest sequence is 11-12-13-14-15, so the function would return 5. Your job is to optimize the function so that it takes O(N) time.arrow_forward
- Write a program that will read the monthly salary of 10 employees and then calculates the income tax (i.e, 10% of the salary) and net salary. Hence you have to declare an array salary[10][3]. Your program should have 4 functions. The first function will be used to read monthly salary of 10 employees and put it in the first column of the array. The second function will be used to calculate the income tax for each employee and then store it in the second column of the array. The third function will be used to calculate the net salary of each employee and store it in the third column of the array. Finally, the fourth function will be used to display the gross salary, income tax and net salary for each employee. You must pass the array as reference in each function you used.arrow_forwardplease do this program in java in details. You have been given two random integer arrays as arr1 and arr2 of size n and m respectively. Boththe arrays contain numbers from 0 to 9 (i.e. single digit integer is present at every index). The ideahere is to represent each array as an integer in itself of digits n and m.You need to find the sum of both the input arrays treating them as two integers and put the result inanother array i.e. output array will also contain only single digit at every index.Input Format:Line 1: Size of first arrayLine 2: Elements of first arrayLine 3: Size of second arrayLine 4: Elements of second arrayOutput Format:The resultant arraySample Input 1:36 2 437 5 6Sample Output 1:1 3 8 0Sample Input 2:49 7 6 134 5 9Sample Output 2:1 0 2 2 0arrow_forwardCreate a program that reads in an array of strings (AKA a 2D array of char ). The strings should be read through a function that reads a single string at a time, assuming the original array still has space. For example, given a 20 amay of char with size 4x 32 it can store up to 4 strings of length 31. When you first create the array, there are no strings Reading a string using the function should increase the number of strings by 1. If 4 strings have already been read the function should not try and read a new string Define the following function in a file named string_utils.c with its declaration in string_utils.h . In string_utils.h, define MAXSTRINGS = 4 and STASIZE = 32.arrow_forward
- The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Project Specifications Input for this project: Values of the grid (row by row) Output for this project: Whether or not the grid is magic square Processing Requirements Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns…arrow_forwardThe Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Processing Requirements - c++ Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns in the array const int MIN = 1; // The value of the smallest number const int MAX = 9; // The value of the largest number //…arrow_forwardPlease I want this question written in Java programming language. Don’t forget to use documentation and indentation.arrow_forward
- Write the code of dynamic array with the name of ‘A’ and you will get the size of array from user and also get the values of array from the user and display that values on screen. TRY TO ADD COMMENTS IN THE CODE TOOarrow_forwardWrite a program to produce an array of integer random numbers. Yourprogram should find out from the user how many numbers to store. It should then generate and store that many random integers (the random numbers must be between 1 and 999 inclusive). The program should then determine the smallest number, the largest number, and the average of all the numbers stored in the array. Finally, it should print out all the numbers on the screen, five numbers to a line with spaces in between. Once the contents of the array have been printed to screen, display the smallest number, largest number, and average determined previously. You should ensure that your program design in modular.The Random class of Java library (java.util.Random) implements a randomnumber generator. To generate random numbers, you construct an object of q the class Random, and then use the method nextInt(n) which returns a number between 0 (inclusive) and n (exclusive). Eg: import java.util.Random;.....Random generator = new…arrow_forwardPlease submit your solution to the lab instructor once you have your program working. Your lab instructor will tell you how (s)he would like you to turn it in. Failure to submit will result in a zero. Write a program that asks the user to input two integers a and b. Then create an array that has all integer from a to b. Print out the array. (Don’t forget to consider the situation of a=b, a<b, and a>b.) Example 1: Input two numbers: 6 2 Array is [6, 5, 4, 3, 2] Example 2: Input two numbers: 4 8 Array is [4, 5, 6, 7, 8] Pass the above array as a parameter to a method called average and return the average and print it out in the main method. (Do not use Math library to get the average.) Please attach your screenshot below to each question a and b.arrow_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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License