9. Give the values of the following expressions: a. ptrl->info b. ptr2->next->in
ID: 3793468 • Letter: 9
Question
9. Give the values of the following expressions:
a. ptrl->info
b. ptr2->next->info
c. listData->next->next->info
10. Are the following expressions true or false?
a. listdata->next == ptr1
b. ptr1->next->info == 60
c. ptr2->next == NULL
d. listData->info == 25
11. Decide whether the syntax of each of the following statements is valid or invalid, if it is valid, mark it OK; if it is invalid, explain what is wrong.
a. listData->next = ptr1->next;
b. listData->next =*(ptr2->next);
c. *listData = ptr2;
d. ptr2 = ptr1->next->info;
e. ptr1->info = ptr2->info;
f. ptr2 = ptr2->next->next;
12. write one statement to do each of the following:
a. make listData point to the node containing 45.
b. Make ptr2 point to the last node in the list.
c. Make listData point to an empty list.
d. Set the info member of the node containing 45 to 60
Explanation / Answer
Question 9 :-
---------------------------
a. ptr1->info
Answer : 30
As shown in figure , "ptr1" points to node whose "info" value is 30
b. ptr2->next->info
Answer : 90
As shown in figure , "ptr2" points to node whose "info" value is 80. its next node "info" is 90
c. listData->next->next->info
Answer : 45
As shown in figure , "listData" points to start node. its next to next node "info" is 45
Question 10 :-
---------------------------
a. listdata->next == ptr1
Answer : True
As shown in figure , "listData" points to start node. its "ptr1" points to its next node "info" is 30
b. ptr1->next->info == 60
Answer : False
As shown in figure , "ptr1" points to node whose "info" value is 30. its next node "info" is 45
c. ptr2->next == NULL
Answer : False
As shown in figure , "ptr2" points to node whose "info" value is 80. its next node "info" is 90,not a NULL
d. listData->info == 25
Answer : True
As shown in figure , "listData" points to start node. Its "info" is 25
Question 11 :-
---------------------------
a. listData->next = ptr1->next;
Answer : Ok
Synax is correct. listData->next / ptr1->next both are pointers(memory address) so they can be
assigned. This will re arrange the list
b. listData->next =*(ptr2->next);
Answer : Invalid
"listData->next" is pointers(memory address) and "*(ptr2->next)" is the item at pointer "(ptr2->next)"
( * before a pointer indicates actual item at the memory location)
So both can't be assigned. We can assign pointer to another pointer only
c. *listData = ptr2;
Answer : Invalid
"*listData" is the item at pointer "listData" and "ptr2" is a pointer so we can't assign
d. ptr2 = ptr1->next->info;
Answer : Invalid
"ptr2" is pointers(memory address) and "ptr1->next->info" is the integer value, not a Memory address
So can't be assigned
e. ptr1->info = ptr2->info;
Answer : OK
Both are integer values so we can assign
f. ptr2 = ptr2->next->next;
Answer : OK
Both are Memory Address values so we can assign
Question 12 :-
---------------------------
a. make listData point to the node containing 45.
listData = listData->next->next;
b. Make ptr2 point to the last node in the list.
ptr2 = ptr2->next
c. Make listData point to an empty list.
listData = NULL
d. Set the info member of the node containing 45 to 60
node containing 45 is next to "ptr1"
ptr1->next->info = 60
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.