Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use an IDE to create the program Lab1c.cpp as follows. (Lab1c.cpp) Write Lab1c.cpp in the following order. Write A Function Prototype Write a function prototype

Use an IDE to create the program Lab1c.cpp as follows.

(Lab1c.cpp) Write Lab1c.cpp in the following order.

Write A Function Prototype

Write a function prototype for the function named allocIntArray. The function receives an integer parameter for the number of integer values the allocated memory can contain. The function returns a pointer to the first integer value in the allocated memory.

Write The Main Function

Define and initialize a pointer named ptr1 for pointing to an int value.

Define and initialize a pointer named ptr2 for pointing to an int value.

Allocate an array that can contain 100 int values by calling allocIntArray and assign the returned pointer to ptr1.

Store odd numbers starting from 1 into the array.

Allocate an array that can contain 1000 int values by calling allocIntArray and assign the returned pointer to ptr2.

Store even numbers starting from 2 into the array.

Print partial contents of the first array on the screen.

Print partial contents of the second array on the screen.

Delete the memory allocated for the first array.

Delete the memory allocated for the second array.

Write the function definition for allocIntArray

Write the block comment that describes the function name, what the function does, the parameter and the return value.

In the function body,

Use the new operator to allocate an array of integers using the parameter as the size of the array.

Return the pointer that is returned by the new operator.

Test the program

The output should look exactly as follows.

1 3 5 ... 195 197 199

2 4 6 ... 1996 1998 2000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

F. The training manual for managers are online.

Answered: 1 week ago