In the following code both myList and yourList are dynamic arrays of the same size. The code initializes the array myList to certain values. The value in each element of yourList should be twice the value in the corresponding element in myList. However, the output of this code would show that is not the case. Provide the correct code to accomplish the desired results. int *myList;int *yourList;myList = new int[5];myList[0] = 8;for (int i = 1; i < 5; i++)myList[i] = i * myList[i - 1];yourList = myList;for (int i = 0; i < 5; i++)yourList[i] = 2 * myList[i];
In the following code both myList and yourList are dynamic arrays of the same size. The code initializes the array myList to certain values. The value in each element of yourList should be twice the value in the corresponding element in myList. However, the output of this code would show that is not the case. Provide the correct code to accomplish the desired results. int *myList;int *yourList;myList = new int[5];myList[0] = 8;for (int i = 1; i < 5; i++)myList[i] = i * myList[i - 1];yourList = myList;for (int i = 0; i < 5; i++)yourList[i] = 2 * myList[i];
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
In the following code both myList and yourList are dynamic arrays of the same size. The code initializes the array myList to certain values. The value in each element of yourList should be twice the value in the corresponding element in myList. However, the output of this code would show that is not the case. Provide the correct code to accomplish the desired results.
int *myList;
int *yourList;
myList = new int[5];
myList[0] = 8;
for (int i = 1; i < 5; i++)
myList[i] = i * myList[i - 1];
yourList = myList;
for (int i = 0; i < 5; i++)
yourList[i] = 2 * myList[i];
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images