Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include 
using namespace std;

int st[100],top=-1;

void push(int x)
{
    st[++top] = x ;
}

void pop()
{
    if(top==-1) printf("Stack Overflow");
    else  printf("Delete = %d\n",st[top--]);
}

int main()
{
    push(10);
    push(100);
    push(-25);
    pop();
    pop();
    return 0;
}


What I have tried:

C++
int main()
{
int n;
cin >> n;
    push(10);
    push(100);
    push(-25);
    pop();
    pop();
    return 0;
}
Posted
Updated 21-Nov-22 0:50am
v2
Comments
Patrice T 10-Mar-16 0:08am    
What is the problem ?
Explain what you want to do.
OriginalGriff 10-Mar-16 2:06am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So all we have is some stack code and a simple test method - you need to explain what your homework needs in more detail.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

The easiet way to get user input is with scanf.

C++
printf("Enter a int number");
int number = 0;
scanf("%d",&number);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900