Created
April 12, 2017 09:27
-
-
Save aswanthkoleri/6e41d4712fc832b8ed2170559c38c327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int isempty(int top) | |
{ | |
if(top==-1) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} | |
int isfull(int top,int n) | |
{ | |
if(top==(n)-1) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} | |
void push(int st[],int *top,int data,int n) | |
{ | |
if(isfull(*top,n)) | |
{ | |
printf("pushing not possible"); | |
} | |
else | |
{ | |
*top++; | |
st[*top]=data; | |
} | |
} | |
int pop(int st[],int *top){ | |
int temp; | |
if(isempty(*top)) | |
{ | |
return printf("the pop operation is not possible "); | |
} | |
else | |
{ | |
temp=st[*top]; | |
*top--; | |
return temp; | |
} | |
} | |
int main() | |
{ | |
int st[50],n,st,top=-1; | |
printf("enter the stacksize"); | |
scanf("%d",&n); | |
push(st,top,4,n); | |
push(st,top,5,n); | |
push(st,top,6,n); | |
push(st,top,7,n); | |
push(st,top,8,n); | |
pop(st,top); | |
pop(st,top); | |
printf("The stack is "); | |
for(i=0;i<(top+1);i++) | |
{ | |
printf("%d",st[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment