includeltstdiohgtint choice stack10 top


include

int choice, stack[10], top, element;

void menu();

void push();

void pop();

void showelements();

void main()

{

choice=element=1;

top=0;

menu();

}

void menu()

{

printf("Enter any options from following:\n");

printf("PUSH 1\n POP 2\n DISPLAY ELEMENTS 3\n EXIT 4\n");

scanf("%d", &choice);

if (choice==1)

{

push();

menu();

}

if (choice==2)

{

pop();menu();

}

if (choice==3)

{

showelements();

menu();

}

void push()

{

if (top<=9)

{

printf("Enter any element to be pushed to stack:\n");

scanf("%d", &element);

stack[top]=element;

++top;

}

else

{

printf("Stack full\n");

}

return;

}

void pop()

{

if (top>0)

{

--top;

element = stack[top];

printf("Popped element:%d\n", element);

}

else

{

printf("Stack empty\n");

}

return;

}

void showelements()

{

if (top<=0)

printf("Stack empty\n");

else

for(int i=0; i

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

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: includeltstdiohgtint choice stack10 top
Reference No:- TGS0413458

Expected delivery within 24 Hours