1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vinvika [58]
2 years ago
15

9.11: Array Expander

Computers and Technology
1 answer:
vodka [1.7K]2 years ago
3 0

The Array Expander is an illustration of arrays and functions.

  • Arrays are variables that stores multiple values
  • Functions are named statements that are executed when called

<h3>The Array Expander program </h3>

The Array Expander program written in C++, where comments are used to explain each action is as follows:

#include <iostream>

using namespace std;

//This declares the Array Expander function

int* ArrayExpander(int *oldArr, int size){

   //This declares the new array

   int *newArr = new int[size * 2];

//This iteration sets values into the new array

   for (int i = 0; i < size * 2; i++) {

       if(i < size){

           *(newArr+i) = *(oldArr+i);

       }

       else{

           *(newArr+i) = 0;

       }

   }

//This returns a pointer to the new array

   return newArr;

}

//The main method begins here

int main(){

//This declares the length of the array, N

   int N;    

//This gets input for N

   cin>>N;

   int initArr[N];

//If N is between 1 and 50

   if(N > 0 && N <=50){

//This iteration gets values for the array

       for(int i = 0; i<N; i++){

           cin>>initArr[i];

       }

//This calls the Array Expander function

   int *ptr = ArrayExpander(initArr, N);

//This iteration prints the elements of the new array

   for (int i = 0; i < N*2; i++) {

       cout << ptr[i] << " ";

   }

   }

  return 0;

}

Read more abou C++ programs at:

brainly.com/question/27246607

You might be interested in
You just purchased a single license for the latest Microsoft Office Suite. Your friend has asked to borrow the CD, so he can ins
TiliK225 [7]

Answer:

B

Explanation:

No, this would be piracy. If he would want to install it, he would have to buy it himself.

Hope this helps :D

6 0
3 years ago
Does anyone know edhesive 4.3 question 1
navik [9.2K]

No

.................................. :)

5 0
3 years ago
Read 2 more answers
When an online company runs a special promotion on swimsuits during the summer, they are taking advantage of the concept of
LenaWriter [7]
<span>When an online company runs a special promotion on swimsuits during the summer, they are taking advantage of the concept of p</span>eople’s urge to go for swimming to beat the summer heat and keep themselves cool. As a result, they are very likely to buy more swimsuits to go swimming. 
With a special promotion on swimsuits, people are likely to buy the company’s merchandise. This is because they can get what they want by paying a lesser amount than usual. In turn, the company is able to benefit by making more sales than its online and retail competitors.

6 0
3 years ago
Read 2 more answers
Please
levacccp [35]

Answer:

inspect

Explanation:

7 0
3 years ago
What is the final value of the string output given the following code fragment? int counter = 0; int num = 0; string output = ""
swat32

int counter = 0;

int num = 0;

string output = "";

while (counter < 3) {

num = num * 1;

counter = counter + 1; }

output = Convert.ToString(num);

Output:

Counter = 0

num = 0 * 1 - - > num = 0

Counter = 1

num = 0 * 1 - - > num = 0

Counter = 2

num = 0 * 1 - - > num = 0

Counter = 3 (break)

num = 0

output = "0"

3 0
4 years ago
Other questions:
  • Gerry used html for her website. which best describes html
    15·1 answer
  • Which of the following describes a poor design consideration for a form?
    14·1 answer
  • Which line of code will allow a decimal point to be stored in a variable?
    11·1 answer
  • What is the definition of delimited text?
    14·2 answers
  • Which console was the first to use CD-ROM storage
    5·1 answer
  • . What is the difference between a combinational circuit and sequential circuit? Give example of each.
    8·1 answer
  • What kind of power does Tesla Model S, 3 X, and Y use?
    8·2 answers
  • The five types of personal computers are: desktops, laptops, tablets, smartphones, and ________.
    13·1 answer
  • What the five types of initiatives that are necessary when putting together and implementing an IT strategy
    9·1 answer
  • Which web browser was created by Google?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!