Need a little help with printing a stack

This is a discussion on Need a little help with printing a stack within the C Programming forums, part of the General Programming Boards category; Originally Posted by Shyam Raj @root: Hello root, thanks for your detailed reply. You're welcome Originally Posted by Shyam Raj ...

  1. #16
    Registered User
    Join Date
    Nov 2012
    Posts
    23
    Quote Originally Posted by Shyam Raj View Post
    @root: Hello root, thanks for your detailed reply.
    You're welcome
    Quote Originally Posted by Shyam Raj View Post
    Regarding how to do it, from your explanation I understand that you're saying - print an element every time you push it. And similarly print the element only you've popped it. Let me know if I've not got it right. If not, give me a small hint, I might me able to do it .

    Thanks in advance.
    I don't know how to give a hint, I'm trying to explain it in a high level pseudocode
    Code:
    function print_stack(stack s)
    
    if the stack isn't empty then
                   x<-pop(s)
                   print x
                   call print_stack function passing s, that is, call after call without the top element
          
    push(x);
    Last edited by root; 11-15-2012 at 11:21 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack
    By BEN10 in forum C Programming
    Replies: 1
    Last Post: 08-29-2009, 12:43 AM
  2. Printing non-printing characters in ^ and M- notation
    By sbeard22 in forum C Programming
    Replies: 6
    Last Post: 10-04-2008, 12:12 AM
  3. How is stack map
    By Shidlingayya in forum C Programming
    Replies: 4
    Last Post: 08-17-2007, 03:39 AM
  4. Need Help with Stack
    By trongsi in forum C++ Programming
    Replies: 9
    Last Post: 05-23-2006, 05:14 PM
  5. Incorrect Output when Printing a Stack
    By Zildjian in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2004, 11:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21