Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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
Step: 1
a The string input by the user must have the property of being a palindrome for the program to print ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started