Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.2, Problem 14STE
What is the output of the following code fragment? The code is assumed to be embedded in a correct and complete
int arraySize = 10;
int *a;
a = new int[arraySize];
int i;
for (i = 0; i < arraySize; i++)
* (a + i) = i;
for (i = 0; i < arraySize; i++)
cout << a[i] << “ ”;
cout << endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
write a function that performs this array manipulation with the given parameters.
array manipulation:
original array = {1,2,3}
array after function = {1,2,2,3,3,3}
void array_manip( unsigned int*& array, size_t& size) { }
please use C++
In java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed. (ONLY ARRAYS or ARRAYLIST)
Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated.
Develop a function that returns true if the elements are in decreasing order and false otherwise.
A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks.
Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8,…
Write a function that gets an array as a parameter (address and size) and a number and checks to see if that number exists in the array. The function should report every single occurrence of the number in the array. It should also report how many occurrences were detected in total (use c code)Suggested prototype:
void findnReport(int* ar, int size, int num)
Example of function output:
If array = {2,5,3,5,12,13,14,15,0,5,-1,11,5} and num = 5,
Number 5 found in array index 1
Number 5 found in array index 3
Number 5 found in array index 9
Number 5 found in array index 12
Total of 4 occurrences of number 5
Chapter 9 Solutions
Problem Solving with C++ (9th Edition)
Ch. 9.1 - Prob. 1STECh. 9.1 - Prob. 2STECh. 9.1 - Give at least two uses of the operator. State...Ch. 9.1 - Prob. 4STECh. 9.1 - Prob. 5STECh. 9.1 - Suppose a dynamic variable were created as...Ch. 9.1 - Write a definition for a type called NumberPtr...Ch. 9.1 - Prob. 8STECh. 9.2 - Write a type definition for pointer variables that...Ch. 9.2 - Suppose your program contains code to create a...
Ch. 9.2 - Prob. 11STECh. 9.2 - Prob. 12STECh. 9.2 - What is the output of the following code fragment?...Ch. 9.2 - What is the output of the following code fragment?...Ch. 9.2 - What is the output of the following code fragment?...Ch. 9 - Prob. 1PCh. 9 - Write a program that asks the user to input an...Ch. 9 - Palindrome testing with pointers This Practice...Ch. 9 - Do Programming Project 3 in Chapter 7 in this...Ch. 9 - Do Programming Project 11 in Chapter 7 using a...Ch. 9 - Write a function that takes a C string as an input...Ch. 9 - Prob. 5PPCh. 9 - One problem with dynamic arrays is that once the...Ch. 9 - Prob. 7PPCh. 9 - Write a program that outputs a histogram of...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Modify your printDetai 1 s method to include printing the reference number. However, the method should print th...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
List the specific functions of a DBMS.
Database Concepts (8th Edition)
How are relationships between tables expressed in a relational database?
Modern Database Management (12th Edition)
Write the function htoi(s), which converts a suing of hexadecimal digits (including an optional 0x or 0X) into ...
C Programming Language
Define the three types of recursive binary relationships, and give an example of each, other than the ones show...
Database Concepts (7th Edition)
Look at the following class: public class Checkpoint { public void message(int x) { System.out.print(This is th...
Starting Out with Java: From Control Structures through Data Structures (3rd 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
- In java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed. 1. Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. 2. Develop a function that returns true if the elements are in decreasing order and false otherwise. 3. A "peak" is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. 4. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function…arrow_forwardOne dimension array in C:Create an array of 100 integer elements and initialize the array elements to zero.Populate the array (using a for loop) with the values 10,20,30,..., 990,1000.Write code (using for loops) to sum all the elements and output the sum to the screen. without using #definearrow_forwardWrite a function void switchEnds(int *array, int size);that is passed the address of the beginning of an array and the size of the array. The function swaps the values in the first and last entries of the array.arrow_forward
- Functions with 2D Arrays in Java Write a function named displayElements that takes a two-dimensional array, the size of its rows and columns, then prints every element of a two-dimensional array. Separate every row by a new line and every column by a space. In the main function, call the displayElements function and pass in the required parameters. Output 1 2 3 4 5 6 7 8 9arrow_forwardIn c++ , perform insertion into the dynamic array at the start, end, and middle as well and perform array resizing as well. ( Drop code in words , explain the code and drop the screenshot of output as well )arrow_forwardUse C++arrow_forward
- Two dimension array in C:Create a two dimension array of integers that is 5 rows x 10 columns.Populate each element in the first 2 rows (using for loops) with the value 5.Populate each element of the last three rows (using for loops) with the value 7.Write code (using for loops) to sum all the elements of the first three columns and output thesum to the screen.arrow_forwardsolition in C++arrow_forwardExercise #1: Write a C program that contains the following steps. Read carefully each step as they are not only programming steps but also learning topics that explain how numeric arrays in C work. Write a while loop to input a series of numbers (either from a file or from the keyboard, but using a file will make for easier debugging) into a one dimensional array of type double named x_arr, declared to be 25 elements in length. Count the elements as you input them. Then in a second loop, a for loop this time, print out all the elements which were input. Make up your own data file for this problem. Extend your code by writing a for loop to find the largest value in the array. The largest value should go into a variable named xhigh. Your code should then print out xhigh. Extend your code by writing a for loop to find the smallest value in the array. The smallest value should go into a variable named xlow. Your code should then print out xlow. Extend your code to produce a second array…arrow_forward
- CODE USING C++ 1. Please Fix Me by CodeChum Admin Hi dear Programmer, I am broken. Can you please help me fix me? ?? Instructions: In the code editor, you are provided with a main() function that declares an array, sets its values, and then prints the sum of all of its values. However, there is a problem with how the array is declared. The array should be able to store 5 values. Your task is to fix the me array's declaration. Output 25arrow_forwardC++arrow_forwardplease code in python Forbidden concepts: arrays/lists (data structures), recursion, custom classes You have been asked to take a small icon that appears on the screen of a smart telephone and scale it up so it looks bigger on a regular computer screen.The icon will be encoded as characters (x and *) in a 3 x 3 grid as follows: (refer image1 ) Write a program that accepts a positive integer scaling factor and outputs the scaled icon. A scaling factor of k means that each character is replaced by a k X k grid consisting only of that character. Input Specification:The input will be an integer such that 0 < k ≤ 10. Output Specification:The output will be 3k lines, which represent each individual line scaled by a factor of k and repeated k times. A line is scaled by a factor of k by replacing each character in the line with k copies of the character. [refer image2]arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License