View the step-by-step solution to:


I am trying to write code that reads a line and converts to upper case to lower and lower to upper but while

placing each letter in a queue and onto a stack then verify that if its a palindrome or not and I am stuck.


Write program that reads a line of text, changes each uppercase letter to lowercase, and places each letter both in a queue and onto a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward).

#include <iostream>

#include <string>

#include <cctype>

#include <stack>

#include <queue>

using namespace std;

int main()


   string input;

   getline(cin, input);

   for (int a = 0; a < input.length(); a++)


      input[a] = tolower(input[a]);


   cout << input << endl;

   stack<string> inputStack;

   queue<string> inputQueue;



   bool isPalindrome = true;

   for (int a = 0; a < input.length(); a++)


      isPalindrome *= input[a] == input[input.length() - 1 - a];


   if (isPalindrome)


      cout << "This is a palindrome";




      cout << "This is not a palindrome";


   return 0;


//   if (lower >= 'a' && lower <= 'z') {

//      //

//      //

//      upper = ('A' + lower - 'a');

//   }

//   else {

//      upper = lower;

//      cout(" The uppercase letter is %cn", upper);

//      return 0;


//   }


Top Answer

View the full answer

Madam Non Madam
madam non madam
This is a palindrome
Process exited after 10.81 seconds with return value 0
Press any key to continue
Wow Mam Wow
wow mam wow
This is a palindrome
Process exited...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online