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
Alborosie
3 years ago
8

Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the

number of elements to allocate. The function should return a pointer to the array. Call the function in a complete program.
Computers and Technology
1 answer:
viktelen [127]3 years ago
5 0

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

int* integerArr( int number);

int main(){

   int* address;

   address = integerArr(5);

   for ( int i = 0; i < 10; i++ ) {

     cout << "Address of the integer array:  ";

     cout << *(address + i) << endl;

   }

   return 0;

}

int* integerArr( int number){

   int myArr[number];

   for (int i = 0; i < number; ++i) {

     myArr[i] = rand();

   }

   int* ptr= myArr;

   return ptr;

}

Explanation:

The C++ source calls the defined pointer function "integerArr" with an integer argument to declare arrays of dynamic length, in the main function of the program and the items of the array are printed on the screen.

You might be interested in
Juan wrote a loop to print all the prime numbers between 1 and 100. But instead of stopping at 100, it continues on and on forev
aniked [119]

Answer:

oh im cool

Explanation:

6 0
2 years ago
Consider the scenario below and determine the most likely source of the problem. A user reports that her or his printer is not r
Lina20 [59]
The answer would be D.

4 0
2 years ago
Read 2 more answers
Which of the following is the biggest issue facing wireless communication today?
anygoal [31]

Answer:

threats to privacy

Explanation:

7 0
3 years ago
What Windows utility can enable you to shut down an unresponsive application?
boyakko [2]

Answer:

Task manager

Explanation:

Allows you to force quit applications.

4 0
2 years ago
Read 2 more answers
Ann has always wanted to be the person on the news broadcast who delivers the weather updates. She’s looking into becoming a bro
Marrrta [24]
The answer should be A.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a C++ program in which you declare variables that will hold an hourly wage, a number of hours worked, and a withholding pe
    12·1 answer
  • Write a program that receives an character and displays its Unicode. Here is a sample run: Enter an character: E The Unicode for
    8·1 answer
  • Having data in a column formatted differently based on value is known as
    7·1 answer
  • Hurry im TIMED
    8·1 answer
  • Viruses which activate themselves after a specific time is called
    10·2 answers
  • the front desk of the Nocete's Hotel will comlute the total room sales (TRS) of Room 101.The room was occupied three times and t
    6·1 answer
  • Change the following sentences using 'used to
    12·1 answer
  • python. create a program that asks the user to input their first name and their favorite number. Then the program should output
    12·1 answer
  • What were the names of Henry VIII's six wives?
    9·2 answers
  • The rectangular symbol in flowchart<br> is used to denote dash
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!