answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#define MAX 10

typedef struct stack

{

int item[MAX];

int Top;

}stk;

void createstack(stk *);

void push(stk *,int);

int pop(stk *);

int isempty(stk *);

int isfull(stk *);

int main()

{

int choice;

int value;

stk s;

createstack(&s);

do{

clrscr();

printf("\n\t Main Menu");

printf("\n1. Push");

printf("\n2. Pop");

printf("\n3. Exit");

printf("\nEnter your choice=");

scanf("%d",choice);

switch(choice)

{

case 1: printf("\nEnter the value to be inserted=");

scanf("%d",value);

push(&s,value);

getch();

break;

case 2: value=pop(&s);

if (value==0)

printf("\n Underflow: Stack is empty");

else

printf("\n Popped Element is %d",value)

getch();

break;

case 3: exit();

defualt: printf("\nInvalid choice");

}

}while(1);

return 0;

}

void createstack(stk *s)

{

s->Top=-1;

}

void push(stk *s,int element)

{

if(isfull(s))

{

printf("\nOverflow: Stack is full");

return;

}

s->Top++;

s->item[s->Top]=element;

printf("\nValue is pushed onto the stack");

}

int pop(stk *)

{

int popped;

if (isempty(s))

return 0;

popped=s->item[s-.Top];

s->Top-;

return popped;

}

int isempty(stk *)

{

return s->Top==-1;

}

int isfull(stk *)

{

return s->Top==MAX-1;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How many stacks needs to implement queue?

One.


What is the minimum number of stacks of size 10 required to implement a queue to size 10?

2 stacks required


What are application of stack?

Stacks are primarily used to implement backtracking algorithms.


Is String a linear data structure?

yes it is, other linear data structures are lists,queues,stacks,arrays


How can you implement a queue using stacks efficiently?

To implement a queue using stacks efficiently, you can use two stacks. One stack is used for enqueueing elements, and the other stack is used for dequeueing elements. When dequeueing, if the dequeue stack is empty, you can transfer elements from the enqueue stack to the dequeue stack to maintain the order of elements. This approach allows for efficient implementation of a queue using stacks.


C program for insertion and deletion in stacks?

chk out the following link showing you how to implement stack. Though it is a c++ implementation it may still help you. http://thetechnofreaks.com/2011/10/26/4-creating-a-stack/#ixzz1bvp8FXdb


C plus plus program using a stacks converting a postfix-infix?

Yes


How do you implement stack without array?

Stacks are often implemented using the same node structure as a linked list.


How many stacks of 100 dollar bills are in 193000000?

193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks.


How do you insert stacks footer?

stacks footer


Where would one find information about stacks?

That would depend on what type of stacks, or stacks of what objects, the individual is looking for. Long Island University has a comprehensive document online that guides the reader through the organization and uses of library stacks, or the shelves on which books are housed. Cisco offers tutorials on Stack protocol in computer systems. Lyrics for the song Stacks by Bon Iver can be found on YouTube and lyrics sites such as Metro Lyrics. Businesses called Stacks range from bookstores to coin and collectibles outlets to clothing boutiques.


What are stacks of thylakoids called?

granum are stacks of thylakoids. grana are several stacks of thylakoids. :)