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
Which type of network consists of multiple Windows computers that share information, but no computer on the network serves as an
Alexxandr [17]

The type of network that consists of multiple Windows computers that share information is peer-to-peer. In this network, the computer serves as an authoritative source of user information.

<h3>Peer-to-peer computer networks</h3>

A peer-to-peer (P2P) network can be defined as a type of network where the computer acts as a source of user information.

In P2P, a cluster of different computers are linked and they have the same permissions for processing data in the network.

This type of computer network (peer-to-peer computer network) has been created to serve and/or receive data.

Learn more about peer-to-peer computer networks here:

brainly.com/question/1172049

7 0
2 years ago
What happens to formulas with relative cell references when they are copied using the fill handle?
Masteriza [31]
The correct answer is D
4 0
4 years ago
How to do the for loop in python
shusha [124]

Answer:

To loop through a set of code a specified number of times, we can use the range() function, The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.

Explanation:

hope this helps

8 0
3 years ago
Using the C language, write a function that accepts two parameters: a string of characters and a single character. The function
Sav [38]

Answer:

#include <stdio.h>

void interchangeCase(char phrase[],char c){

  for(int i=0;phrase[i]!='\0';i++){

      if(phrase[i]==c){

          if(phrase[i]>='A' && phrase[i]<='Z')

              phrase[i]+=32;

          else

              phrase[i]-=32;      

      }

  }

}

int main(){

  char c1[]="Eevee";

  interchangeCase(c1,'e');

  printf("%s\n",c1);

  char c2[]="Eevee";

  interchangeCase(c2,'E');

  printf("%s\n",c2);    

}

Explanation:

  • Create a function called interchangeCase that takes the phrase and c as parameters.
  • Run a for loop that runs until the end of phrase and check whether the selected character is found or not using an if statement.
  • If the character is upper-case alphabet, change it to lower-case alphabet and otherwise do the vice versa.
  • Inside the main function, test the program and display the results.
8 0
3 years ago
True or false
Semmy [17]
It’s false I hope this helped you
3 0
3 years ago
Other questions:
  • Remember that the function "main" takes optional parameters, these being common:
    10·1 answer
  • What is something you can do to stay connected to the relationships in your life while we spend this time at home?
    13·1 answer
  • In Word, blue underlining indicates which of these problems?
    12·1 answer
  • Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to
    10·1 answer
  • Which of the following data recording procedures is best used for behaviors that have a clear ending and beginning, do not occur
    12·1 answer
  • Murray is a database technician. He has created a single enterprise database system. How is this better than multiple databases
    15·1 answer
  • Suppose that a 2M x 16 main memory is built using 256kB x 8 RAM chips and memory is word addressable, how many RAM chips are nec
    6·1 answer
  • Data ____ refers to the accuracy of the data in a database
    9·1 answer
  • You received an email message stating that your mother's bank account is going to be forfeited if you do not respond to the emai
    6·1 answer
  • Please help ASAP!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!