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
A computer with 5 stage pipeline like the one descrive in class delas with conditional branches by stalling for the next three c
trasher [3.6K]

Answer:

It hurts 80%

Explanation:

7 0
4 years ago
What tool allows you to search external competitive intelligence research?
enot [183]

Answer:

SocialPeta

Explanation:

4 0
2 years ago
"where is a cookie that is created during a web site visit​ stored?"
tino4ka555 [31]
On the visitor's computer
5 0
3 years ago
Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
Wewaii [24]

Answer:

The correct answer is option (A).

Explanation:

Pinterest has turned to amazon for storage as a service because it continuously needs a large amount of storage as given in the scenario.

While the other options are not correct because of the following reasons:

  • Grid computing can be defined as the concept of connection between a large number of computers in an architectural way who work to obtain the same goal but grid computing can not fulfill the need for storage for Pinterest.
  • Cloud computing can work as data storage which can be accessed from the internet anywhere but this can not fulfill the storage requirements for Pinterest as they are very huge.
  • Infrastructure as a service is not correct because the need of the company is for storage.

4 0
4 years ago
How do you change the top and bottom margins of an entire document
Elodia [21]
Deep depending on the document editor, you should be able to just click either the top or bottom margin to edit!
6 0
4 years ago
Other questions:
  • How to tell if screen or screen protector is cracked?
    5·2 answers
  • Write a C program that reads a string containing text and nonnegative numbers from the user and prints out the numbers contained
    6·1 answer
  • Which of the following will affect the size of your monthly mortgage payment? A The size of your down payment B The length of yo
    5·1 answer
  • How to be cool idk who can awnser this but i know the cleetus can
    13·2 answers
  • What are the three parts of a Function
    12·1 answer
  • Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
    6·1 answer
  • An inserted graphic in Excel is
    12·2 answers
  • One example of a <br> is the length of a car.
    7·1 answer
  • What is the function of ROM?
    10·1 answer
  • Watch any film of the silent era. Choose a short film from any genre that is less than 30 minutes long. Write a review of your e
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!