Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- const int SIZE = 10;
- int stack_Data[10];
- int top = -1;
- int push(int number);
- int pop();
- int Top();
- int main()
- {int counter = 0;
- while(counter<10){
- push(counter);
- counter++;
- }
- while(counter<10){
- printf("%d\n",stack_Data[counter]);
- }
- return 0;
- }
- int pop(){
- int temp;
- temp = stack_Data[top];
- top--;
- return temp;
- }
- int push(int number){
- if(top>SIZE){
- printf("Stack is full\n try popping a few elements\n");
- return 1;
- }
- else{
- top++;
- stack_Data[top]=number;
- }
- return number;
- }
- int Top(){
- if(top<0)
- printf("Stack is now empty\n");
- return -1;
- return stack_Data[top];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement