Answer to Question #237559 in C++ for Lovely

Question #237559
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();

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS