What is the output of the following C++ code? (3, 4) a. while (current != nullpt
ID: 3678348 • Letter: W
Question
What is the output of the following C++ code? (3, 4)
a. while (current != nullptr)
cout << current->info << " ";
current = current->link;
cout << endl;
b. while (current != last)
current = current->link;
cout << current->info << " ";
cout << endl;
Explanation / Answer
Here is the Answers.
What is the output of the following C++ code? (3, 4)
a. while (current != nullptr)
cout << current->info << " ";
current = current->link;
cout << endl;
Answer:
1) If the same code has been used it will print 75 and space and goes to infinite loop.
2) If you place a { after the while statement and place } after endl; the output will be
75
35
86
10
50
28
65
39
spaces are printed after all the numbers printed .
3)If you place a { after the while statement and place } after current->link; the output will be
75 35 86 10 50 28 65 39
b. while (current != last)
current = current->link;
cout << current->info << " ";
cout << endl;
Answer:
1) If the same code has been used, it goes to infinite loop.
2) If you place a { after the while statement and place } after endl; the output will be
35
86
10
50
28
65
spaces are printed after all the numbers printed .
3)If you place a { after the while statement and place } after current->info; the output will be
35 86 10 50 28 65
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.