Write a short C program that declares and initializes (to any value you like) a double, an int, and a char. Next declare and initialize a pointer to each of the three variables. Your program should then print the address of, and value stored in, and the memory size (in bytes) of each of the six variables. Use the “%p” formatting specifier to print addresses in hexadecimal. You should see addresses that look something like this: "0xbfe55918". The initial characters "0x" tell you that hexadecimal notation is being used; the remainder of the digits give the address itself. Use proper formatting specifiers for char, int and double. Use the sizeof operator to determine the memory size allocated for each variable. Sample output from your program: The address of char ___ is 0x_______ The address of int ___ is 0x_______ The address of double ___ is 0x_______ The address of char* ___ is 0x_______ The address of int* ___ is 0x_______ The address of double* ___ is 0x_______ The value of char ___ is _______ The value of int ___ is _______ The value of double ___ is _______ The value of char* ___ is 0x_______ The value of int* ___ is 0x_______ The value of double* ___ is 0x_______ The size of char is _______ bytes The size of int is _______ bytes The size of double is _______ bytes The size of char* is _______ bytes The size of int* is _______ bytes The size of double* is _______ bytes

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.1: Addresses And Pointers
Problem 12E
icon
Related questions
Topic Video
Question

Write a short C program that declares and initializes (to any value you like) a
double, an int, and a char. Next declare and initialize a pointer to each of the
three variables. Your program should then print the address of, and value stored
in, and the memory size (in bytes) of each of the six variables.
Use the “%p” formatting specifier to print addresses in hexadecimal. You should
see addresses that look something like this: "0xbfe55918". The initial characters
"0x" tell you that hexadecimal notation is being used; the remainder of the digits
give the address itself. Use proper formatting specifiers for char, int and double.
Use the sizeof operator to determine the memory size allocated for each variable.
Sample output from your program:
The address of char ___ is 0x_______
The address of int ___ is 0x_______
The address of double ___ is 0x_______
The address of char* ___ is 0x_______
The address of int* ___ is 0x_______
The address of double* ___ is 0x_______
The value of char ___ is _______
The value of int ___ is _______
The value of double ___ is _______
The value of char* ___ is 0x_______
The value of int* ___ is 0x_______
The value of double* ___ is 0x_______
The size of char is _______ bytes
The size of int is _______ bytes
The size of double is _______ bytes
The size of char* is _______ bytes
The size of int* is _______ bytes
The size of double* is _______ bytes

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning