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]
1 year ago
15

9.11: Array Expander

Computers and Technology
1 answer:
vodka [1.7K]1 year 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
What steps should be taken to dispose of and recycle plastic?
WARRIOR [948]
Step 1: Collection. The first step in the recycling process is always collecting the plastic material that is to be recycled. ...
Step 2: Sorting. ...
Step 3: Washing. ...
Step 4: Resizing. ...
Step 5: Identification and separation of plastics. ...
Step 6: Compounding.
3 0
3 years ago
The letters a, e, i, o and u are the only vowels. Write a function named vowelUseDict() takes a string t as a parameter and comp
Andru [333]

Please specify the programming language.


3 0
3 years ago
What test must you pass to get you're operators licence
Alina [70]
Behind the wheel, the Florida driving test, turn about, shifting gears, parking, backing up, stop quickly, stop signs, signal & turns
5 0
3 years ago
True or false a weighted inventory system is often tied into player advancement
alekssr [168]

Answer:tayfana

Explanation:true

7 0
2 years ago
What is log in and log out?
Brums [2.3K]
Log in is the feature that allows you to access your electronic account in a website, database or other, also a bank account. Your username and password are stored in cookies  (files that websites use and are stored in your browser) for the session. This is true if we talk about websites.

When you're done, you log out from your account, you disconnect. Cookies are cleared (for websites) and you're out.
8 0
3 years ago
Other questions:
  • What types of automation device might require specialist installer training?
    5·1 answer
  • An effective team would never have​
    9·1 answer
  • In fiberoptic cable, the signal source is__________waves
    7·1 answer
  • A directional antenna issues wireless signals along a(n) ____ direction.
    9·1 answer
  • Network signaling is a function of which layer of the osi model
    10·1 answer
  • Write a function that accepts an integer parameter and returns its integer square root (if it exists). The function should throw
    12·2 answers
  • What are the purposes of a good web page design?
    9·2 answers
  • Which is the highest level of the hierarchy of needs model?
    14·1 answer
  • How are 1gls different from 2gls​
    10·1 answer
  • True or False <br> Hebrew Bible and the Koran were first written in English.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!