C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 7.10E
a)
Program Plan Intro
To write a single code statement to define the variable lptr to be a pointer to an object of type long.
b)
Program Plan Intro
To write a single code statement toassign the address of value 1to lptr pointer variable.
c)
Program Plan Intro
To write a single code statement to print the value of object pointed by lptr .
d)
Program Plan Intro
To write a single code statement to assign the value of object pointed by the lptrto value 2 variable.
e)
Program Plan Intro
To write a single code statement to print the value of variable, value2.
f)
Program Plan Intro
To write a single code statement to print the address of variable, value1.
g)
Program Plan Intro
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt.Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer.Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer.Output (cout) the value pointed to by intPointer and output (cout) the variable someInt,2. Declare a pointer variable charArrPointer and initialize it to point to the first elementof a three-element char array named initials. Write assignment statements to store 'A', 'E', and 'W' into the first three elements of the array POINTED to by charArrPointer. Do NOT store any values directly into the array named initials.3. Output (cout) the data in array charArrPointer and the data in array initials.
4. Copy the following code into your program above main:
struct NodeType {int num;NodeType* next;};5. Copy the following code into your program after main:
NodeType…
A pointer variable cannot be:
A Passed to a function as argument.
B
B Changed within the funcction.
C Returned by a function.
D Assigned as an integer value.
D
Declare an integer pointer variable intPointer. Initialize it to point to an int variablenamed someInt.Assign the value 451 to someInt and output (cout) the variable someInt and output (cout)the value pointed to by intPointer.Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer.Output (cout) the value pointed to by intPointer and output (cout) the variable someInt,
Chapter 7 Solutions
C How to Program (8th Edition)
Ch. 7 - Answer each of the following: The _____ operator...Ch. 7 - Prob. 7.10ECh. 7 - Do each of the following: Write the function...Ch. 7 - (Simulation: The Tortoise and the Hare) In this...Ch. 7 - (Card Shuffling and Dealing Modification) Modify...Ch. 7 - What does this program do, assuming that the user...Ch. 7 - What does this program do?Ch. 7 - Find the error in each of the following program...Ch. 7 - (Maze Traversal) The following grid is a...Ch. 7 - Prob. 7.23E
Knowledge Booster
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
- 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_forwardIf s1 and s2 are pointers of the same type, then s2=s1 is a valid statement.True or false?arrow_forwardCreate 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_forward
- in 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_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
- write 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_forwardConsider 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_forwardTask 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_forward
- Define the term " pointer to void " .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_forwardint *p; where p is a null pointer when:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning