Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Write a statement that declares a pointer to a char named c1 and initialize it with the null pointer. 5. Assume that we have
4. Write a statement that declares a pointer to a char named c1 and initialize it with the null pointer. 5. Assume that we have the following type definition: typedef char * MyLetter; Write a statement using MyLetter that declares a variable named c2 and assign it a dynamic variable initialized with the character literal X. 6. Assume we have declared the following pointer variable d1: double *d1; (A) Write a statement that creates (i.e., allocates) a dynamic array of 25 doubles and assigns it to d1. (B) Write a statement that will destroy (i.e., deallocate) the array pointed to by di. 7. Assume that we have created the following dynamic array: int *nums = new int[3] {10, 20, 30}; (A) Write 2 different ways to output to the display the value of the first element of nums. (B) Write a statement that will change the last element of nums to the value 3. (C) Write a statement to deallocate the array nums and return its memory to the freestore. 8. Assume we have already declared a variable of type int named size and initialized it to some value greater than 0. Write the code to declare a dynamic array of type int that holds size elements and initialize every element of the array to the value -1 using a loop (do not use any C++ shortcuts). You don't need to worry about memory leaks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started