hi
plz i wanna ask
how i can print stack from bottom to top ...

:(
?

Use a second stack. Pop each item off of the first stack, push them onto the second stack, then pop items off the second stack and print them until it's empty.

#include <iostream> 
using namespace std; 
// global variables declation 
struct stack  
{ int  info; 
   struct stack *next; 
}; 
 
class stack1 
{ private: 
    stack *Top; 
    int item; 
public: 
           stack1 () {Top = NULL;}  // constructor, which automatically executes when object of the class will be created 
        void Push() 
                { 
                                        cout<<"enter number"; 
                                        cin>>item; 
                                        stack *Newnode = new stack; 
                                        Newnode-> info = item; 
                                        Newnode-> next = NULL; 
                                        if(Top == NULL) Top = Newnode; 
                                        else 
                                        { Newnode -> next = Top; Top = Newnode; } 
                } 
 
        int Pop( ) 
                {  struct stack *t; 
               item = Top -> info; 
                   t = Top; 
                        Top = Top ->next; 
                        delete t; 
                        return item; 
                } 
 
        bool IsEmpty( ) 
                { if(Top == NULL ) return true; else return false; } 
        void Traverse() 
                {  stack *TopTemp = Top; 
                        do{  
                                                        cout<<TopTemp->info<<endl;  
                                                        TopTemp = TopTemp->next; 
                                                } 
                                                while(TopTemp != NULL); 
                } 
}; //  end of the class 
int main() 
{ 
        stack1  z;  // Creation of an object 
        z.Push(); 
        //cout<<z.Pop()<<endl; 
        z.Traverse(); 
        return 0; 
}

can you plz correct my code ..
i have quiz tomoorow . but i can't solve this question ...

plz help me i have exam tommrow

This went from "how do I print a stack in reverse" to "please fix my code". What's your real problem here?

i didn't ask you to solve ...
i need you to correct my code ,,
if you don't want to correct my code ?????!
write your code
:(

i didn't ask you to solve ...
i need you to correct my code ,,

Those are both the same thing.

if you don't want to correct my code ?????!
write your code

...

Okay, I ran your code and at the very least it works for me. So what's the problem? Seriously.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.