Question: Create the following program: Write a C program that does the following: Declare and initialize 3 variables - a char, int, and double. You can

Create the following program: Write a C program that does the following: Declare and initialize 3 variables - a char, int, and double. You can ask for input from the user, or just "hard code" the values. For example: char letter ='w'; Declare and initialize 3 pointers. Each pointer points to one of these 3 variables. In other words, the first pointer stores the address of the character variable. The second pointer stores the address of the integer variable. The third pointer stores the address of the double variable. Using pointers, output the HEXADECIMAL VALUE (using %p) of the address of the 3 variables by outputting the address stored in the pointer. In other words, output the address stored in the first pointer. Then, output the address stored in the second pointer. Then, output the address stored in the third pointer. Using pointers, output the values of the 3 variables by dereferencing the pointer. In other words, dereference the first pointer and display the character value. Then, dereference the second pointer and display the integer value. Then, dereference the third pointer and display the double value. Using pointers, add 3(three) to the values of the 3 variables by dereferencing the pointers. In other words, dereference the first pointer and add 3 to the value and then reassign the value to the dereferenced pointer. Then, dereference the second pointer and add 3 to the value and then reassign the value to the dereferenced pointer. Then, dereference the third pointer and add 3 to the value and then reassign the value to the dereferenced pointer. For example, here is a parallel example using variable "x": x = x +3; (Except you will be using pointers instead.) Using pointers, output the values of the 3 variables by dereferencing the pointer. In other words, dereference the first pointer and display the character value. Then, dereference the second pointer and display the integer value. Then, dereference the third pointer and display the double value. Now output the three variables. In other words, output the character variable. Then, output the integer variable. Then, output the double variable. Note that the values have been changed by the dereferenced pointers!! Make a simple drawing of the 3 variables and the 3 pointers in memory. Draw 3 boxes, with the names of the variables next to the boxes, and the value of the variable inside the box. Use the the initial value. (The initial values are the values of the 3 variables displayed by your program.) Draw 3 more boxes, with the names of the pointers next to the boxes, the value of the pointers inside the box, and draw an arrow from the pointer to the variable. (The pointer values are the 3 addresses which which are displayed by your program. See the diagrams in the slides for details. Scan your drawing, take photo of your drawing, make a Word file, or create a Google Drawings in Google Drive. Attach the file or share the Google Drawings with me.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!