Asked by Anonymous

What is the output of the following C++ code?

p = list;

while (p!=NULL)
cout << p->info << " ";
p = p->link;
cout << endl;

Answers

Answered by mathstudent
That's code to walk through a linked list. I can't say the exact output because I can't see what the variable "list" is.

Also, there are missing braces after the while statement. If the program is run without braces, and list is not null, the iteration will infinitely loop and print the first element over and over.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions