Write a program using C++,  that contains a function called arrayAllocator that dynamically allocates an array of integers. The function should be called from main() and it should accept an integer argument indicating the number of elements to allocate. The value of each element should be the subscript. The function should return the pointer to the array to main.  The main function displays the values of the array.  The output can look something as follows:

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5RQ
icon
Related questions
Question

 

Write a program using C++,  that contains a function called arrayAllocator that dynamically allocates an array of integers. The function should be called from main() and it should accept an integer argument indicating the number of elements to allocate. The value of each element should be the subscript. The function should return the pointer to the array to main.  The main function displays the values of the array. 

The output can look something as follows: 

Enter an array size: 4
Here are the values in the array:
Element e has the value e
Element 1 has the value 1
Element 2 has the value 2
Element 3 has the value 3
Process exited after 2.652 seconds with return value e
Press any key to continue ..
Transcribed Image Text:Enter an array size: 4 Here are the values in the array: Element e has the value e Element 1 has the value 1 Element 2 has the value 2 Element 3 has the value 3 Process exited after 2.652 seconds with return value e Press any key to continue ..
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning