Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

simple c++ Pointers questions. Look at the following examples and write your answer in the column next to the example. char * name1 = new

simple c++ Pointers questions.

Look at the following examples and write your answer in the column next to the example.

char * name1 = new char[ 6 ]; strcpy( name1, "Henry" ); char * name2 = name1; name1[0] = 'D'; char s1[] = "The rain in Spain falls mainly on the plain." char s2[] = "Hello, World!"; s1[12]=s2[0]; s2[7] = s1[12];
after executing the values of name1 and name2 will be: name1 = ____________________ name2 = ____________________ after executing the values of s1 and s2 will be: s1 = ____________________ s2 = ____________________

2. A program includes the following variable declarations: int i1, i2; int *p1,*p2; List the output produced by the following code sample. In addition, using the examples from class, draw a memory diagram showing the 4 variables i1, i2, p1 and p2. Make sure the pointers have a link to the addresses they point to! Draw these diagrams to show the memory state as things change

Code Sample

Output Generated By The Program

Memory Diagram As Things Change

i1 = 8; i2 = 9; p1 = &i1; p2 = &i2;

cout

*p1 = 10; *p2 = *p1;

cout

p2 = p1; *p2 = 11;

cout

image text in transcribed
18-29 2

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago