Consider the following pseudocode:
declare a stack of characters
while ( there are more characters in the word to read )
{
read a character
push the character on the stack
}
while ( the stack is not empty )
{
write the stack's top character to the screen
pop a character off the stack
}
write c++ code for above
1
Expert's answer
2021-09-15T04:59:00-0400
#include<iostream>
#include<stack>
using namespace std;
int main(){
char s[] = "geeksquiz";
stack<char>s1;
int i =0;
while(s[i]){
s1.push(s[i]);
i++;
}
while ( !s1.empty())
{
cout<<s1.top()<<" ";
s1.pop();
}
}
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment