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
Which creepy character is a user-generated myth in minecraft
horsena [70]
It would be slender man
7 0
3 years ago
Which option allows you to link to a specific slide in another presentation?
tresset_1 [31]
The power-point option for new slide. or maybe duplicate slide.
3 0
4 years ago
Which sequence best describes the evolution of computers?
SVETLANKA909090 [29]

Answer:

d. Mainframes came before minicomputers, which led to the development of microcomputers.

Explanation:

The first <em>mainframe</em> was introduced in 1951: The UNIVAC (UNIVersal Automatic Computer I): large computer systems, for general purpose, with hundreds of users (separated from the computer) and fast computations, typically deployed by large business, industry, and government organizations.

The <em>minicomputers</em> are another class of computers that start to evolve since the late of the 1950s and the beginning of 1960s (like LINC, PDP-1, among many others), and focused on to have a more direct contact with the user or programmer, and because of this, it is said that minicomputers were the first 'personal' computers. They were cheaper than mainframes and with less memory capacity.

Finally, the <em>microcomputers</em> appeared around the beginning of 1970s (Micral), and sometime later (Altair 8800,  Apple II) and were firstly used by hobbyists and computers enthusiasts. The term microcomputers have been supplanted nowadays by 'personal computers'.

 

7 0
3 years ago
What ius the output of double a= (double) (12/5) Systenoutprintln (a)
pogonyaev

Answer:

Command: Systenoutprintln (a)

Output: 2.4

Explanation:

The output is going to be the result of the division, since double variables work with decimal parts.

12 divided by 5 is integer part 2 with modulus 2. So

12/5 = 2 mod 2 = 2 + 2/5 = 2 + 0.4 = 2.4.

The output is the result.

So

Command: Systenoutprintln (a)

Output: 2.4

7 0
3 years ago
The correct order of operations is _____. brackets, exponents, division, multiplication, addition, and subtraction subtraction,
bija089 [108]

brackets, exponents, division, multiplication, addition, and subtraction

6 0
4 years ago
Read 2 more answers
Other questions:
  • Using an LCD projector to show an online video to a group of people is an example of:
    14·1 answer
  • PowerPoint’s _____ feature can assist you in finding answers to questions such as “How can I specify which slides to print?” a.
    6·1 answer
  • Angela recently purchased a new Android smartphone. While purchasing the phone, Angela was told that she would need to set up a
    5·1 answer
  • A microphone is a type of electronic.<br><br> True/Faulse
    14·1 answer
  • Pick an appliance or an electronic device that you use at home that is powered from the wall outlet. Specify which electronics d
    10·1 answer
  • A tax return preparer, routinely publishes a schedule of the fees she charges her clients. For how long must keep copies of the
    7·1 answer
  • When do you use FTP?
    10·2 answers
  • Weird canvas submission, I’ve done directly what the directions say to do to submit it, but it won’t submit
    15·1 answer
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • Using an open connection to a small company's network, an attacker submitted arbitrary queries on port 389 to the domain control
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!