answersLogoWhite

0

#include<stdio.h>

int a[10],i=(-1),st=(-1);

void push();

void pop();

void isfull();

void isnull();

void display();

main()

{

int st=(-1);

int a[10],n,ch,i=(-1);

char choice='Y';

while(choice=='Y' choice=='y')

{

printf(" 1.PUSH\n 2.POP\n 3.IS FULL\n 4.IS NULL\n 5.DISPLAY\n");

printf("Enter your choice :");

scanf("%d",&ch);

switch(ch)

{

case 1:

push();

break;

case 2:

pop();

break;

case 3:

isfull();

break;

case 4:

isnull();

break;

case 5:display();

break;

default:

printf("you have entered a wrong entry.");

}

printf("Do you want to continue?");

scanf(" %c",&choice);

}

}

void push()

{

if(st==(-1))

printf("The stack is empty.");

i=i+1;

if(i>=10)

printf("The stack is full.");

else

{

printf("Enter a number :");

scanf("%d",&a[i]);

st=st+1;

}

}

void pop()

{

if(st==(-1))

printf("The stack is empty. UNDERFLOW condition");

if(st>(-1))

{

printf("The deleted element is :%d",a[i]);

i=i-1;

st=st-1;

}

}

void isfull()

{

if(st<9)

printf("The stack is not full\n");

if(st>=9)

printf("The stack is full");

}

void isnull()

{

if(st==(-1))

printf("The stack is empty");

if(st>(-1))

printf("The stack is not empty");

}

void display()

{

int z;

if (st==(-1))

printf("The stack is empty.");

else

printf("The elements present in the array are :");

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

printf(" %d",a[z]);

printf("\n");

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

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.


How do you write a java menu driven program using function overloading?

To create a menu-driven program in Java using function overloading, define multiple methods with the same name but different parameters to perform various tasks. For example, you could create overloaded calculate methods that accept different data types (e.g., int, double) for performing calculations. In the main method, present a menu to the user, take their choice as input, and call the appropriate overloaded method based on their selection. This allows for a clean and organized way to handle multiple functionalities with similar operations.


What are the advantage and disadvantage of organizing an event?

There are many advantages of event driven programming. This type of programming is the simplest and flexible forms of programming languages. This means the programmer has more control over the program when the user does something. Also, making an event driven program is easy. There are only a few disadvantages that come with the event driven programming. Firstly, sometimes classes are not often reusable and are hard to carry out in other applications. It is also very complex and hard to master.


How write the algorithm of a menu-driven C program?

To write the algorithm for a menu-driven C program, start by defining a loop that displays the menu options to the user. Use a switch-case structure to handle user input, allowing each case to correspond to a different option. Inside each case, implement the functionality for that option, and include a break statement to exit the case. Finally, provide an exit option to terminate the program cleanly when the user selects it.

Related Questions

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


Is operating system an event driven program?

yes


Write c program of menu driven by calculator?

dcdfsadf


What is meant by event driven?

event driven programs do not have a specific pathway in which the programs instructions are executed. different parts of the program are evoked by events that take place during the running of the program.


Best AI-driven solutions?

Scaleos.ai &quot;&quot;ScaleOS.ai Headquarters Bastrop, Texas&quot;&quot; 800- 832-1345 ScaleOS.ai offers AI-driven solutions for service-based businesses to enhance revenue, automate operations, and reduce costs. Their services focus on AI strategies for marketing, sales, operations, and customer service, enabling businesses to scale efficiently with customized, data-driven approaches. AI-driven solutions&quot;


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.


List and briefly define three techniques for IO operations?

Blocking IO: The program will pause and wait until the IO operation is complete before resuming. This technique can lead to inefficiency if there are multiple IO operations. Non-blocking IO: The program continues to run while waiting for the IO operation to complete. This allows for better efficiency when handling multiple IO operations simultaneously. Asynchronous IO: The program initiates the IO operation and continues executing, without waiting for the operation to complete. A callback function is usually provided to handle the result once it is available. This allows for better performance in handling large numbers of IO operations.


How event driven program is different from other program?

In normal (ie imperative) programming, you define a set of operations to be performed sequentially, from start to finish in one go. In event driven programming, you define a series of "callback" functions, which are then called by whatever runtime system you may be using, in response to the actions of the user, or some other agent. Each function is associated with an action (eg the user pressing a button or clicking an icon), and is called by the system whenever the user performs that action.


Why are hills good places to rear sheeps?

Often the hills are too steep and rugged for machinery like tractors and implements to be driven on without risk of flipping over. Hills grow grass, which feeds the sheep.


What does it mean to wear your pants below your buttcheeks?

It means you are a culture-driven, following idiot


Is center lathe a machine tool?

Yes. A machine tool is a power driven machine that is a tool in itself which performs machining operations.


What is a spud barge?

A spud barge has steel pilings which are driven in to the river bed to allow them to stay stationary and allow them to support construction operations.