What is the output, if any, of each of the following C++ statements? (3, 4) a. c
ID: 3830916 • Letter: W
Question
What is the output, if any, of each of the following C++ statements? (3, 4)
a. cout << current->info;
b. current ¼ current->link;
cout << current->info;
c. cout << temp->link->link->info;
d. trail->link ¼ nullptr;
cout << trail->info;
e. cout << last->link->info;
Explanation / Answer
What is the output, if any, of each of the following C++ statements? (3, 4)
a. cout << current->info; //current is pointing to first node, and therefore, current->info will print 75.
b. current ¼ current->link; //I believe this is = symbol, which will move the current to the next node, i.e., a node with value 35.
cout << current->info; //Now current->info will print a value of 35.
c. cout << temp->link->link->info; //temp is pointing to a node with value 86, and therefore, temp->link is pointing to a node with value 10, temp->link->link is pointing to a node with value 50. So, a value of 50 will be printed to screen.
d. trail->link ¼ nullptr; //trail->link = nullptr. This will just disconnect the last node i.e., a node with value 39.
cout << trail->info; //trail->info is 65.
e. cout << last->link->info; //last->link is grounded, i.e., is pointing to null, and will not have info part.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.