New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Implementation of Stack As An Array In C Program


Posted Date:     Total Responses: 0    Posted By: Sunny   Member Level: Diamond   Points/Cash: 4   


#include
#define size 5
char stack[size][15],ele[20];
int tos;
void push();
char* pop();
void show();
int isempty();
int isfull();

int main()
{
int choice;
tos=0;
do
{
printf("\tEnter 1 for push,2 for pop,3 to show,and 4 to exit\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
if (isfull())
printf("\nThe stack is full");
else
{
printf("\n Enter element to insert");
scanf("%s",ele);
push(ele);
}
break;
case 2:
if(isempty())
printf("\n The stack is empty");
else
printf("\nThe removed element is:%s",pop());
break;
case 3:
if(isempty())
printf("\nThe stack is empty, I cant show you any elements");
else
show();
break;
case 4:
exit(1);
default:
printf("\nDo you understand english and numbers??");
}
}while(1);
}
int isempty()
{
return(tos==0);
}
int isfull()
{
return(tos==size);
}
void push(ele)
{
//stack[tos]=ele;
strcpy(stack[tos],ele);
tos++;
}
char* pop()
{
tos--;
return(stack[tos]);
}
void show()
{
int x=tos;
printf("\nThe Stack elements are.....\n");
while(x!=0)
printf("\t%s\n",stack[--x]);
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: C program To convert Infix To Post Fix By using Shunting Yard Alogorithm
Previous Project: Inplementation Of Linked List In C++

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.