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
Proponents of Internet freedom see its _____________ as providing protection for unpopular expression; proponents of greater Int
diamong [38]

Answer:

anonymity

Explanation:

<h2><u>Fill in  the blanks </u></h2>

Proponents of Internet freedom see its <u>anonymity </u>as providing protection for unpopular expression; proponents of greater Internet control see it as the Internet's greatest danger.

6 0
3 years ago
Which framework can be used to develop cross-platform applications?
k0ka [10]

Answer:

Qt framework

Explanation:

3 0
3 years ago
Brian needs to assign a macro to a button on the ribbon. Where should he go to achieve this goal?
8_murik_8 [283]

Answer: A. Record Macro dialog box.

Explanation:

3 0
3 years ago
Read 2 more answers
If cos 3/5 what is the sin and tan​
suter [353]

Answer:2.988584094

Explanation:

6 0
3 years ago
The byte that
qwelly [4]
The decimal value 15 would be A. 00001111
4 0
1 year ago
Other questions:
  • 4. Who developed the first design technology program which had a
    12·1 answer
  • When considering changing the content of a cell which button should you press to leave the cell as it originally was? 
    5·1 answer
  • What are some options available in the Spelling and Grammar Checker? Check all that apply. Change and Change All Redo and Repeat
    15·2 answers
  • What Is an Antivirus?
    14·2 answers
  • If you are running a server , which of the follow operating system would be best suited ?window 10 or macOS
    8·1 answer
  • Anybody wants to join my pad let to talk about video games
    7·2 answers
  • How to work a computer cause i don't know how to
    15·1 answer
  • Vector images take up much less space when saved to a computer or storage device because computers and storage devices just need
    14·2 answers
  • What symbol should you look for to determine who owns the intellectual property of a website? the logo the web address the domai
    7·2 answers
  • I watched an ad but the im button done is no where in sight, has anyone else experienced this recently. it was fine a few days a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!