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
user100 [1]
3 years ago
12

Write a function that accepts an int array and the array’s size as arguments. 1. The function should create a new array that is

twice the size of the argument array. 2. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. 3. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads
Computers and Technology
1 answer:
Contact [7]3 years ago
4 0

Answer:

The question seems to be incomplete. Analyzing the full question the answer has been explained below. Please let me know if your answer requirement was other than this.

Explanation:

#include<iostream>

#include<fstream>

using namespace std;

int *extend(int arr[], int N)

{

  // create a new array that is twice

  //the size of the argument array.

  int *new_arr = new int[2 * N];

  int i;

  // copy the contents of the argument

  //array to the new array

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

      new_arr[i] = arr[i];

  // initialize the unused elements

  //of the second array with 0

  for (i = N; i < 2 * N; i++)

      new_arr[i] = 0;

  // return a pointer to the new array

  return new_arr;

}

//main function

int main()

{

  // Declare the array

  int N;

  //Prompt and reads an integer N

  cout << "Enter N : ";

  cin >> N;

  // If the integer read in from

  //standard input exceeds 50 or is less than 0

  if (N < 0 || N > 50)

      // The program terminates silently

      exit(0);

  // open file in read mode

  ifstream in("data.txt");

  // create an array of size N

  int *arr = new int[N];

  int i;

  // reads N integers from a file

  //named data into an array

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

  {

      // read integer from file

      in >> arr[i];

  }

  //then passes the array to your

  //array expander function

  int *new_arr = extend(arr, N);

  // print the extended array

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

      cout << new_arr[i] << endl;

  in.close();

  return 0;

}

You might be interested in
Why computers are called "COMPUTER"?
Lady_Fox [76]

Because it ‘computes’ certain tasks, get it. It’s like saying ‘the puncher’ for someone who punches stuff.

8 0
4 years ago
Your school has been declared a school of technology
Angelina_Jolie [31]
I don't really understand the meaning of the question. Can you reply and i'll try to help...
7 0
4 years ago
Use the ________ method to write text to a web page.
Nastasia [14]
Document.write()

I'm not sure that this is a method, but I think this is right. 
3 0
4 years ago
Fire stick optimizing system storage and applications
vivado [14]

Answer:

IN MY PROFILE

Explanation:

I HAVE AWNSERED THIS QUESTION THROUGHOUT MY BEING HERE PLEASE DO NOT BE AFRAID TO CLICK ON MY PROFILE AND FIND THE ANSWER

5 0
3 years ago
Universal Containers has a requirement to integrate Salesforce with an external system to control record access.
Alenkasestr [34]

Answer:

C.  Use the SOAP API to maintain the related SObject_share records

Explanation:

In order to ensure that Universal Containers have complete control over the system, the company needs to use certain requirements. This is to ensure that non-authorized persons do not have any access to the information. Based on the information provided in the question, the correct option is option C.

3 0
4 years ago
Other questions:
  • You have a network that needs 29 subnets while maximizing the number of host addresses available on each subnet. How many bits m
    13·1 answer
  • Write an expression to print each price in stock_prices. sample output for the given program: $ 34.62 $ 76.30 $ 85.05
    6·1 answer
  • Windows server 2012 r2 includes hyper-v in which edition(s)?
    12·1 answer
  • If you plan on operating several applications at s time, the amount of RAM should be considered when purchasing a computer
    10·2 answers
  • _____ are special combinations of keys that tell a computer to perform a command.
    9·2 answers
  • Nielsen purchases scanner data from retail transactions to track the sales of consumer packaged goods, gathered at the point of
    14·1 answer
  • What happens if the addressed device does not respond due to a malfunction during a read operation?
    11·1 answer
  • In what decade was photography invented? the 1800s the 1820s the 1840s the 1860s
    15·1 answer
  • For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a comma (no sp
    6·1 answer
  • Computer Graphics:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!