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



‘C’ program using pointers to implement a stack with all the operations


Posted Date:     Total Responses: 0    Posted By: Sunil Reddy   Member Level: Platinum   Points/Cash: 2   



#include
#include

int size;
struct stack
{
Int a[max];
Int top;
};
void stk(struct stack *st)
{
st->top = –1;
}
void push(struct stack *st,int num)
{
If(st->top == size–1)
{
printf(“\n over flow\n”);
return;
}
st->top++;
st->a[st->top]=num;
}
Int pop(stuct stack *st)
{
Int num;
If(st->top==-1)
{ printf(“stack is under folw\n”);
return NULL;
}
num=st->a[st->top];
st->top—;
return num;
}
void display(struct stack *st)
{
Int i;
for(i=st->top;i>=0;i—)
printf(“\n %d\t”,st->a[i]);
}
void main()
{
Int d,i,n;
struct stack *ptr;
do
{
printf(“\n menu items\n1.push \t 2.pop\t3.display\t
4.exit\n”);
printf(“enter your choice:”);
scanf(“%d”,&i);
switch(i)
{
case 1: printf(“enter an element:”);
scanf(“%d”,&n);
push(&ptr,n);
break;
case 2: d=pop(&ptr);
printf(“\n deleted item %d”,d);
break;
case 3: printf(“elements of the stack are \n”);
display(&ptr);
break;
case 4: exit (0);
default: printf(“invalid choice”);
}
}
getch();
}


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 sort a given list of elements using tree sort
Previous Project: WinCalculator

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.