MUST BE WRITTEN IN C Programming Unit 4 Assignment 1 In your textbook, C: How to
ID: 3692842 • Letter: M
Question
MUST BE WRITTEN IN C Programming
Unit 4 Assignment 1
In your textbook, C: How to Program, please complete the following:
Chapter 7: page 320 & 321, Exercises 7.7 & 7.10
7.7 Answer each of the following:
The __________ operator returns the location in memory where its operand is stored.
The __________ operator returns the value of the object to which its operand points.
To simulate pass-by-reference when passing a nonarray variable to a function, it’s necessary to pass the __________ of the variable to the function.
7.10 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.
1. Define the variable lPtr to be a pointer to an object of type long.
2. Assign the address of variable value1 to pointer variable lPtr.
3. Print the value of the object pointed to by lPtr.
4. Assign the value of the object pointed to by lPtr to variable value2.
5. Print the value of value2.
Print the address of value1.
Print the address stored in lPtr. Is the value printed the same as the address of value1?
Explanation / Answer
7.7)
a) The operator returns the location in memory where its operand is stored.
ANS: address(&)
b) The operator returns the value of the object to which its operand points.
ANS: indirection (*).
c) To simulate call-by-reference when passing a nonarray variable to a function, it is necessary topass the of the variable to the function.
ANS: address.
7.8)
a)Define the variable lPtr to be a pointer to an object of typelong
.
ANS: long*lPtr;
b)Assign the address of variablevalue1to pointer variablelPtr
.
ANS: lPtr = &value1;
c)Print the value of the object pointed to by lPtr
.
ANS: printf(“%ld ”, *lPtr );
d)Assign the value of the object pointed to by lPtrto variablevalue2
.
ANS: value2 = *lPtr;
e)Print the value of value2
.
ANS:printf(“%ld ”, value2 );
f)Print the address of value1
.
ANS: printf(“%p ”, &value1 );
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.