answersLogoWhite

0


Best Answer

#include

#include

#include

#define MAXSIZE 50

int a[MAXSIZE];

int top=-1;

void main()

{

int choice;

void push();

int pop();

void display();

clrscr();

do

{

printf("\nYou can do following operations on stack\n");

printf("\n1. Push");

printf("\n2. Pop");

printf("\n3. Display");

printf("\n4. Exit");

printf("\n Enter your choice");

scanf("%d",&choice);

switch(choice)

{

case 1: push();

break;

case 2: pop();

break;

case 3: display();

break;

case 4: break;

default: printf("\n Wrong input");

}

}while(choice!=4);

getch();

}

void push()

{

int value;

if(top==MAXSIZE-1)

{

printf("\n Stack is overflow");

}

else

{

printf("\n Enter the value which you want to insert");

scanf("%d",&value);

top++;

a[top]=value;

}

}

int pop()

{

int value;

if(top==-1)

{

printf("\nStack is underflow");

return(0);

}

else

{

value=a[top];

top--;

}

return value;

}

void display()

{

int i;

if(top==-1)

{

printf("\n Stack is underflow");

}

else

{

for(i=top;i>=0;i--)

{

printf("\n%d",a[i]);

}

}

}
#include < stdio.h >

#include < conio.h >

#define MAX 10

int stack[MAX],top;

void main()

{

char ch;

int choice,item;

void display();

int pop();

void push(int);

clrscr();

top=-1;

do

{

printf("1.Insertion");

printf("\n2.Deletion");

printf("\n3.Display");

printf("\nEnter your choice(1-3):");

scanf("%d",&choice);

switch(choice)

{

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

scanf("%d",&item);

push(item);

display();

break;

case 2: item=pop();

printf("\nThe item deleted is %d",item);

display();

break;

case 3: display();

break;

default:printf("Wrong choice");

break;

}

printf("\nDo you want to continue(y/n):");

fflush(stdin);

scanf("%c",&ch);

}while(ch=='y' ch=='Y');

getch();

}

void push(int item)

{

if(top==MAX-1)

{

printf("Stack Overflow");

return;

}

top=top+1;

stack[top]=item;

}

int pop()

{

int t;

if(top==-1)

{

printf("Stack Underflow");

return -1;

}

t=stack[top];

top=top-1;

return t;

}

void display()

{

int i;

printf("\nThe Stack elements are:");

for(i=0;i < =top;i++)

printf("%5d",stack[i]);

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a Menu driven program for a stack operation?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the output of menudriven program for stack operation?

First, you see the menu. The rest depends on what you choose from the menu.


Menu driven program in c programming?

You can find the source code of the menu driven graphics program here: http://www.start2code.com/Cresources/menu-driven-graphics-program-c.html


What is the meaning of the menu driven program?

Menu-driven simply means you execute the application's commands by selecting them from a menu, as opposed to command-driven whereby you enter (type) the commands manually.


Write c program of menu driven by calculator?

dcdfsadf


What is menu driven application?

Term used to describe a software program that is operated using file menus instead of using commands. Below is an example of how a user may quit a menu-drivenprogram, as opposed to a non menu-driven program.Menu-drivenWithin an open program, the user clicks the "File" option from the drop down menu bar and selects QuitNon menu-drivenUser presses the "!" key and then presses the "q" key to quit the program.A menu-driven environment like most programs in Microsoft Windows is easier for users as it is a graphical environment and allows the user to navigate using the mouse. A non menu-driven environment like the command line can be quicker, but requires more memorization and is more difficult for new computer users.


When did Operation Menu happen?

Operation Menu happened on 1969-03-18.


Menu-driven Programming in visual basic?

Develop a menu driven proramming in C++ on Examination System ?


How does a datavision program work?

Data Vision is an accounting package software. It helps one in managing their sales, purchases, inventory, and production. The program works in a menu-driven format.


What is a menu-driven?

With a menu driven interface the user interacts with the computer by selecting options from a menu, rather than memorizing syntax rules of commands.NB: The "windows" of the programmes in a menu-driven interface are created by symbols since creating of windows is not supported by DOS.


What operating system is Minicom compatible with?

Minicom is compatible with Mac operating system, Linux, and POSIX. This program is developed by Adam Lackorzynski and Martin A. Godisch. This program is used for communication which is driven by menu.


Where is the page menu in chrome?

The page menu can be there in the stack icon on the top right. The button can be clicked to obtain the complete menu.


What are three possible interfaces an OS provides to the user?

Command-driven, menu-driven, or icon-driven