Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Describe in detail (more than ~100 words) what is the address of a variable. Give various types of examples. 2. What would print from

1. Describe in detail (more than ~100 words) what is the address of a variable. Give various types of examples.

2. What would print from the following segment of code. Explain each output and why it is what it is.

int x = 24;

int *intptr;

intptr = &x;

cout << x << endl;

cout << *intptr << endl;

cout << intptr << endl;

*intptr = 100;

cout << *intptr << endl;

cout << intptr << endl;

3. How can you use pointer to print the first element of an array? Give an example.

4. Explain the Program Output listed on page 507, Program9-7 of the text book. How does the pointer notation work with array name?

5. When you increment/decrement a pointer, are you changing the address or the element at the address? If it is the address, how does the program now how much to increment or decrement? Hint: Remember the use of sizeof function in earlier chapters.

6. Explain the difference between the following; assuming ptr1 and ptr2 are pointers to integers.

a. If (ptr1 < ptr2)

b. If (*ptr1 < *ptr2)

7. Read section 9.8 on pages 522-526 and answer the following:

a. Why do we need dynamic memory allocation?

b. What commands are used to allocate and release memory?

c. What is memory leak, and how do you prevent it?

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

What are the determinants of cash cycle ? Explain

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago