Question: (a) State exactly what property the string input by the user must have for the program below to print Yes... Explain the program logic
(a) State exactly what property the string input by the user must have for the program below to print "Yes..." Explain the program logic concisely but clearly (i.e. give the key steps). (2 marks) int main() { } char c; bool check = true; stack cstack; queue cqueue; cout < < "Enter a string and press return." < < endl; cin.get( c ); while (c!= ' ') { } cstack.push( c ); cqueue.push( c ); cin.get( c ); while (check && !cqueue.empty() ) { } if (cstack.top() != cqueue.front()) check = false; cstack.pop(); cqueue.pop(); if (check cout < < "Yes it is!" < < endl; else cout < < "No it's not." < < endl; return 0; (b) Explain clearly what performance issue the above program has, and suggest how to fix it. No code is needed; just explain briefly. (2 marks)
Step by Step Solution
There are 3 Steps involved in it
a The string input by the user must have the property of being a palindrome for the program to print ... View full answer
Get step-by-step solutions from verified subject matter experts
