Concept explainers
Suppose you have the following array declaration in your program:
int yourArray[7];
Also, suppose that in your implementation of C++, variables of type int use 2 bytes of memory. When you run your program, how much memory will this array consume? Suppose that when you run your program, the System assigns the memory address 1000 to the indexed variable yourArray[0]. What will be the address of the indexed variable yourArray[3]?
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Mechanics of Materials (10th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Introduction To Programming Using Visual Basic (11th Edition)
Modern Database Management
Concepts Of Programming Languages
- Write a C++ program that prompts the user to enter the rows, and columns in each rowtocreate a 2D dynamicarray. Make sure that each row in 2D array should contain different number of columns. Fill the array bytaking the values from the user and display the contents of 2D array. Now store the contents of this 2Darray into a newly created 1D dynamic array in such a way that it stores the data column-wisearrow_forwardwrite a c++ program in wich you have to Declare a two-dimensional array which can be used to store a yearly budget.Each row of the array corresponds to a particular budgeted item like rent, electric,etc. There are at most 15 items to be budgeted. Each column of the array correspondsto a month, January, February, etc. Of course there are 12 columns corresponding tothe 12 months of the year. All the data to be placed in the array consists of realnumbers.arrow_forwardWrite a program in C Language which fulfills the following criteria a. Declare 3D array named “array3d" with the dimension of 2 x 3 x 4 b. Assign random numbers to array3d by using the function rand(). The range of random number must be between 0 to 99. c. Copy all the contents of “array3d" to new matrix called array3d_new by using the addresses of memory location. Keep in mind that you have only the initial or starting address of mattrix array3d. You need to show and print that address. Perfom the task by calling functions. d. In "array3d" there are 4 copies of 2 x 3 matrix, add the respective elements of the first two matrix in a new matrix called sum2d_a (the dimension of this newly created matrix is 2 x 3). Perform the same task for the remaining two matrixes and store the result in sum2d_b. Now create the new matrix namely sum2d containg both copies of sum2d_a and sum2d_b with the matrix size of 2 x 3 x 2. You need to perform all these tasks using FUNCTIONS. e. Write a function to…arrow_forward
- Write a function in C language that will take a 2D Array of size 3x3 from the user. Your Program should: 1. Prompt the user to enter 2D array of size 3x3. 2. Calculate the sum of all rows. 3. Calculate the sum of all columns 4. Return 1 if the sum of all rows is greater than sum of all columns, 0 otherwise. Your main program should print the result based on the returned values.arrow_forwardI wrote this code in c programming. what this code should do is ask how many times its going to run and run that many times(this works), ask how many books there are in a place(this works), then ask the max number of pages you want to read(this works), then asks how many pages there are in a book and put that into an array(works), then sorts the array of pages(works), and then adds the number in the array until you cant which is less than or equal to the max number of pages you want to read, and puts how many books you read(does not work), and then prints out how many books you read. a sample input is 35 206 12 3 10 25 2112 3 6 10 210 319 6 6 3 8 2 12 15 13 7 sample out put should be 345 #include <stdio.h> #include <stdlib.h> void MergeSort(int values[], int start, int end); void Merge(int values[], int start, int middle, int end); void add(int pages[], int count[], long long maxPages, long long total); void Print_Array(int count[], int cases); int main(void) {…arrow_forwardWrite a C++ program that creates a 2D integer array of user-defined row size only. Initially, it has only 1 column, but it asks that does the user want to add a column to the array and then takes integer values to fill up the newly created column. It continues to do so until the user enters N/n to exit the program. For Example: Matrix: 1 2 4 8 Do you want to Add a column: y Enter the values in columns: 7 9 So updated Matrix is: Matrix: 1 2 7 4 8 9arrow_forward
- Give an example of a C++ code snippet that performs some operation on an array (e.g. sort, search, fill, modify, etc). You should have at least six lines of executable C++ code and your code should be different than anyone else's. Then state the runtime of your code snippet, but don't state what the algorithm is.arrow_forwardHi, i need help with this program in C++ Write a program that asks the user to enter the size of an array. Declare a dynamic array of type int of the size entered by the user. Initialize the array so that the elements in the first half have values equal to the square of the index, and the elements in the second half have values equal to three times the index. Print out the array with 15 values per line.arrow_forwardWrite a C# program that creates an integer array of size 10 and fills the array with numbers set by the programmer (not entered by the user). Then, the program will create two arrays, one of them contains only the odd values of the original array, and the other contains the even values. Note that the size of the newly created arrays should be equal to the number of elements in the array. For example, if the original array contains three odd values, the size of the array that contains the odd values should be equal to three.arrow_forward
- Write a C program that takes an array from the user and calculates how many array elements are prime numbers. YOU HAVE TO USE POINTERS TO DO ALL THE ARRAY OPERATIONS(ELEMENT BY ELEMENT) prime numbers are whole numbers greater than 1 that have only two factos, 1 and the number itself.arrow_forwardWrite a program in C Language which fulfills the followingcriteriaa. Declare 3D array named “array3d” with the dimension of 2 x 3 x 4b. Assign random numbers to array3d by using the function rand(). The range ofrandom number must be between 0 to 99.c. Copy all the contents of “array3d” to new matrix called array3d_new by usingthe addresses of memory location. Keep in mind that you have only the initial orstarting address of mattrix array3d. You need to show and print that address.Perfom the task by calling functions.d. In “array3d” there are 4 copies of 2 x 3 matrix, add the respective elements ofthe first two matrix in a new matrix called sum2d_a (the dimension of this newlycreated matrix is 2 x 3). Perform the same task for the remaining two matrixes andstore the result in sum2d_b. Now create the new matrix namely sum2d containgboth copies of sum2d_a and sum2d_b with the matrix size of 2 x 3 x 2. Youneed to perform all these tasks using FUNCTIONS.e. Write a function to find the…arrow_forwardwrite a c++ program that takes array values as an input .for each array element, find the difference between that element and last array element and update the array. Take array size from user= 6 example: input array: 1, 4, 5, 6, 7, 2arrow_forward
- 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