Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 9, Problem 7PP
Program Plan Intro
Emulating 2D arrays with 1D array
Program Plan:
- Include the necessary libraries.
- Use namespace.
- Create an emulated two-dimensional array with the given number of rows and columns.
- Define a function “set()” to store value in the desired position in an emulated two-dimensional array
- Define a function “get()” to retrieve the value in the desired position in an emulated two-dimensional array.
- Define the main method.
- Define the constants.
- Declare the variables that are required for program.
- Create a two-dimensional array.
- Display the array contents and get the input values.
- Declare the array size and assign the values into it.
- Use a “for” loop to repeat operation until user requires.
- Display all non-repeated letters.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++
For this week’s assignment, you’ll be making a function that can multiply not only two matrices, but also a single matrix and a scalar. To build a matrix in C++, you’ll need to familiarize yourself with multi-dimensional arrays. These are the same as regular arrays, but when you initially define them, instead of saying:Int dataArray[10];You’d say:Int dataArray[10][10];This will create an array of 100 objects, that you can think of in a 10 x 10 grid. It should be noted that it’s actually the same as saying ‘int dataArray[100]’, and can be used in the same way.You can also initialize two-dimensional arrays like this:Int matrix[2][3] = {{ 0, 1, 2} ,{3, 4, 5}};Or like this:Int matrix[2][3] = {0,1,2,3,4,5};One of them’s just slightly easier to recognize as a two dimensional array than the other. Now while THIS project is only dealing with 2x2 matrices, it will be to your benefit if you plan your program to be able to handle matrices of any size...Your function will need to correctly…
In C programming:
Write a main() function using the following requirements:• Define a SIZE constant (the value is irrelevant, but for testing, you may want to keep it small enough – no bigger than 5)• Create an array of course pointers using SIZE• Dynamically allocate each element of the array• Call inputAllCourses()• Call printAllCourses().
Write in c++
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...
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
- Write C++ application with several functions that deal with a two-dimensional array of positive integers: The number of rows and number of columns of the array should be 20. Fill the array with random numbers between 1 and 1000. Display a table that contains the array values, numbers (elements of the array) should be aligned. Display the indexes, for example (rowIndex,columnIndex), where the prime numbers are stored. Display a table of the same size of the input array that contains the array values of prime numbers that you found. Do not show the composite numbers in the array. That is, you should leave out blanks for the composite numbers or put zeros in that position.arrow_forwardcode in C++ Design and implement a structured program for manipulating arrays data structures, as follow: 1- Use two dimensional string array data structure of five rows and six columns to store the data of five students, each student is identified by (stid, fname, and four final marks). 2- Then, split the above array into two other two dimensional arrays: a- One for the (stid, and the fname) for the five students. b- The other for (stid and the four final marks). c- Show the contents of the new array (stid and the four final marks). d- Prepare test data and implement it (run).arrow_forwardIn c programming without pointer and function Problem Statement A matrix is a 2D array of numbers arranged in rows and columns. We give you a Matrix of N rows and M columns. Now your task is to do this operation on this matrix: If the value matches with the current row and column number then add 3 with the value. If the value matches with only the current row number then add 2 with the value. If the value matches with only the current column number then add 1 with the value. Input Format The first line contains N is the number of rows in this matrix and M is the number of columns in this matrix The second line contains a 2D array Arr[i][j]. Constraints 1 <= N, M <= 10 0 <= Arr[i][j] <= 100 Output Format Print the matrix after the operation is done. Sample Input 0 3 31 1 11 1 11 1 1 Sample Output 0 4 3 3 2 1 1 2 1 1arrow_forward
- Solve the below program in C language. Write a program in C to get the largest element of an array using the function. Test Data :Input the number of elements to be stored in the array :5Input 5 elements in the array :element - 0 : 1element - 1 : 2element - 2 : 3element - 3 : 4element - 4 : 5Expected Output : The largest element in the array is : 5arrow_forwardUse C Language Pascal’s Triangle Version 2 The Pascal triangle can be used to compute the coefficients of the terms in the expansion (a + b)n. For example, (a + b)2 = a2 + 2ab + b2 where 1, 2, and 1 are coefficients. Write a C program that creates a two-dimensional matrix a representing the Pascal triangle of size n. For example, a Pascal triangle of size 10 is shown below:arrow_forwardin c++ language pleasssearrow_forward
- In C language please(Please use arrays tysm)arrow_forwardCourse : Data Structures & Algorithms in C++ Question : Consider the following array values and apply quick sort on it. Only dry run is required but you have to show all steps:10 3 8 5 12 2 15 4 1arrow_forwardOne Dimensional in C Program Traverse through the one-dimensional array and perform based on the following: If the currently traversed element is a positive number, print the cube of that number. Otherwise if it is a negative number, print the square of that number. Print each results with a new line. An array containing 40 integer elements is already provided for you in the code editor below. Just fill in the blanks. Output: The squares and cubes of the elements in the array, separated by a line 1 4 9 8arrow_forward
- Code for this in C: Write a C program using two-dimensional arrays that gets 2x2 matrix input from the user and then prints the resultant matrix.arrow_forwardWhat is the difference between normal array and dynamic array?arrow_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_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning