Concept explainers
a)
To write a single code statement to define the variable lptr to be a pointer to an object of type long.
b)
To write a single code statement toassign the address of value 1to lptr pointer variable.
c)
To write a single code statement to print the value of object pointed by lptr .
d)
To write a single code statement to assign the value of object pointed by the lptrto value 2 variable.
e)
To write a single code statement to print the value of variable, value2.
f)
To write a single code statement to print the address of variable, value1.
g)
To write a single code statement to print the address stored in lptr and to state that the value of lptr is same as of value1 or not.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
- Using C++ Programming language: Given the following definitions: int num1=1, num2=2; int *ptr1=NULL, *ptr2=NULL; Write the following statements: Assign ptr1 to the address of num1. Assign ptr2 to the address of num2. Using pointer notation, write a statement that compares the values that the pointers "point" to to see which is larger. (There is more than one way to do this. You choose.)arrow_forwardin C For each of the following, write a single statement that performs the indicated task. Assume that long integer variables value1 and value2 have been defined and that value1 has been initialized to 200000. a) Define the variable lPtr to be a pointer to an object of type long. b) Assign the address of variable value1 to pointer variable lPtr. c) Print the value of the object pointed to by lPtr. d) Assign the value of the object pointed to by lPtr to variable value2. e) Print the value of value2. f) Print the address of value1. g) Print the address stored in lPtr. Is the value printed the same as the address of value1?arrow_forwardIf s1 and s2 are pointers of the same type, then s2=s1 is a valid statement.True or false?arrow_forward
- Create a function that can accept a pointers and array with values of 1000, 2, 3, 17, 50. Your program will display the array values and its averagearrow_forwardA pointer variable can contain a pointer to a single variable, a pointer to an array, nullptr, or a random value. Write code that creates and sets four pointer variables a, b, c, and d to show each of these possibilities.arrow_forward16. NULL can be assigned to a void pointer. True O Falsearrow_forward
- Task related to pointers : Write a c++ program that asks the user to enter integers as inputs to be stored in the variables 'a' and 'b' respectively. There are also two integer pointers named ptrA and ptrB. Assign the values of 'a' and 'b' to ptrA and ptrB respectively, and display them. ( Drop code in words , explain the code and drop the screenshot of output as well )arrow_forwardwrite a single statement that performs the specified task. Assume that long variables value1 and value2 have been declared and value1 has been initialized to 200000 ."Assign the address of variable value1 to pointer variable longPtr .arrow_forwardPointer Activity You do not need getopt for this program as there are no arguments. Call the executable pointers. Create variables for a character, a string, an integer, and a floating point number. Create pointers for each of those variables. Ideally, use the same name as the variable but add a p in front of the name. (For example: (total and ptotal) Ask the user to enter information for each of these variables one at a time. For each variable tell them what they should enter. (For example: “Enter a single character” or “Enter a floating point number”) Read in the information and put it in the variables. Make each pointer point to the respective variable. Print out values for the four variables without using the variables themselves. Only use the pointers. In addition print out the addresses of the memory locations that each pointer points to. You can use %p for that. Output should look like the bottom sample. Copy and paste the code and the output into a Word document and submit.…arrow_forward
- Consider the following scenario: you are given three numbers. Create a program to determine which of three numbers is the greatest and which is the lowest. Pointers are being used.arrow_forwardDefine the term " pointer to void " .arrow_forwardHow may the address of a variable be added to a pointer variable? Why is the code below problematic?arrow_forward
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning