stacks and queues help please!!

hi guys, i have 2 questions about stacks and queues. i found some hints about them from here but i can't write programs these are the following questions. please help me to write these short programs..

Stacks Please write a short program that reads one after the other a the characters ’C’,
’O’, ’M’, ’P’, U’, ’T’, ’E’, ’R’ from the command line and pushes it to the stack of
characters with the name x. Then apply the operations top and pop and print the
popped elements on the screen. Test if the program runs for both the contiguous
implementation of stacks, as well as the linked implementation.


Queues Please write a short program to test the behavior of the queue implementations,
therefore please create a queue of integers of size 5. Append 1,2,3,4,5 to the queue,
then apply 10 Append and serve operations indicating if the append or serve was
successful. Test this short program for linear and physical implementation. What
is the difference?
What have you done so far?
i use for loop. i wrote a program with numbers but i cannot find a way for letters

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

int main ()
{
stack<int> mystack;

for (int i=0; i<5; ++i) mystack.push(i);

cout << "Popping out elements...";
while (!mystack.empty())
{
cout << " " << mystack.top();
mystack.pop();
}
cout << endl;

return 0;
}

i wrote something like that. but i can't find way for c o m p u t e r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
string text;
int i = 0;
stack<char> mystack;

cout << "Write the text\n";
cin >> text;

while(text[i] != '\0')
{
  mystack.push(text[i]);
}

while(!(mystack.empty))
{
  cout << mystack.top;
  mystack.pop;
}
Topic archived. No new replies allowed.