Question: 5. Consider the following program, and draw the resulting list for an input of 3, 7,-9,-4, 5, -1, 0, be sure to include top

5. Consider the following program, and draw the resulting list for an input of 3, 7,-9,-4, 5, -1, 0, be sure to include top and bottom. { #include using namespace std; void main() struct link { int info; link *next;}; = link top, bottom, *lptr; int val, oval 0, ival = 1; top =bottom = 0; cin >> val; while (val != 0) { lptr new link; lptr->info = val; 1ptr->next = 0; if (!top) { top bottom lptr; } else if (val next top = 1ptr; top; } else { bottom->next = lptr; bottom bottom->next; cin >> val; ival *= -1; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
