Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Exercise) Create-pointers.c Use your favorite text editor to aeate a C program called pointers.c and following code to your fie y the Irt main 4

image text in transcribed

(Exercise) Create-pointers.c Use your favorite text editor to aeate a C program called pointers.c and following code to your fie y the Irt main 4 retum i TPS activity 3 Paired with the same classmabe siting next to you and discuss questions (15 minutes) 1. How many variables were declared in line 1? How many of them are pointers and what are they)? 2. What will be the values of x, y, and arr[O iIf you run the program? Valldate your answer by running the program. Why do you think it happens that way? You will need to insert print statements to display those values. 3. How do you prevent x, y, and the content of arr from having unexpected values? Try to fix them in the program. . The moment you have declared a varlable, the program will alocate a memory location for It. Each memory location has an address. Now insert print statements to display the addresses of x, y 5. Now insert code so that px points to x and py points to y. Print out the values and addresses of those pointers using only the pointer varlables (yes, pointers have addresses tool) You should see that value of px equals to address of x and the same is true with py and y. 6. As weve learned in lectures, an aray name can be used as a pointer to access the content of the aray. Write a loop to print out the content of arr by using arr as a pointer (do not use ) 7. Are array names really the same as pointers? Lets find outl An array name points to the first element of an array, so arr should point to the address of arr 0]. Insert code to verify thib. 8. Now print out the address of arr. Does the result make sense? Why? 9. Your TA ll "Invlte one of you randomly to share what you have discussed

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