What is the output of the following program?  < Assume there is NO syntax error> struct st { int info; struct st *next; }; struct st *list, *ptr; list = new st; list -> info = 20; ptr = new st; ptr -> info = 36; ptr -> next = NULL; list -> next = ptr; ptr = new st; ptr -> info = 40; ptr -> next = list; list ->next->next = ptr; list->next->info=99; list->next->next->next = ptr->next; ptr = list->next->next; while ( ptr != list ) { cout << “ List -> info value is “ << list -> info << " " << endl; list = list->next; } return 0; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 9SA
icon
Related questions
Question
100%

What is the output of the following program? 
< Assume there is NO syntax error>
struct st
{ int info;
struct st *next;
};
struct st *list, *ptr;
list = new st;
list -> info = 20;
ptr = new st;
ptr -> info = 36;
ptr -> next = NULL;
list -> next = ptr;
ptr = new st;
ptr -> info = 40;
ptr -> next = list;
list ->next->next = ptr;
list->next->info=99;
list->next->next->next = ptr->next;
ptr = list->next->next;
while ( ptr != list )
{ cout << “ List -> info value is “ << list -> info << " " << endl;
list = list->next;
}
return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning