Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to check if the user\'s input is palindrome or not. You shou

ID: 3631156 • Letter: W

Question

Write a C++ program to check if the user's input is palindrome or not. You should use both stack and queue. Has to compare string in queue and stack to see if they are the same, if so then it will pop. Modify program in visual studio c++.
ex)what I need to do: stack(column) a  b  c  a  queue(row) a b b a if it doesnt match use break.
 if it does pop until empty. Allow user to input string.



#include <iostream>
#include <queue>
#include <stack>
#include <string>
using namespace std;

int main (){

queue<int> MyQueue;
stack<int> MyStack;

string input="my name";

int Queue;
int Stack;

//declare a char Queue and a char stack
//string.at[i]
for (int i=0;i<input.length();i++)
{
cout<<input.at(i)<<" ";
}
cout<<endl;
for (i=0; i<10; i++)

{
MyQueue.push(input.at(i));
MyStack.push(input.at(i));
}
//push characters into stack and queue
cout<< "MyQueue:"<<endl;
for (i=0; i<10;i++)
{
cout<<MyQueue.front()<<" ";
MyQueue.pop();
}
cout<<endl;
cout<< "MyStack:"<<endl;
for (i=0; i<10; i++)
{

cout<<MyStack.top()<<" ";
MyStack.pop();
}//end while
cout<<endl;

if (MyStack.top==MyQueue.front)
{
MyStack.pop();
MyQueue.pop();
}
else

break;

if (!MyStack.top==MyQueue.front)


return 0;
}

Explanation / Answer

here is how I did it for my assignment, Hope this helps !!...... #include #include #include int palindrome(char a[],char b[]); void main() { clrscr(); char a[30],b[30]; int i,m,j,n; printf("Please enter a string "); gets(a); m=palindrome(a,b); if(m==0) { printf("Palindrome "); } else { printf("Not Palindrome "); } getch(); } int palindrome(char a[],char b[]) { int i,j,m,n; n=strlen(a); for(i=0,j=n-1;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote