Miss Natthida Sengmanotham 2CPR2
Miss Natthida Sengmanotham 2CPR2
#include <stdio.h>
void clearStack()
{
top = -1;
printf("\t\t\tProcess is successfull");
}
void main()
{
int choice, e, s[5];
do
{
system("cls");
printf("\t\t\t MENU \n");
printf("\t\t\t 1.push \n");
printf("\t\t\t 2.pop \n");
printf("\t\t\t 3.display\n");
printf("\t\t\t 4.Check top value \n");
printf("\t\t\t 5.Clear stack \n");
printf("\t\t\t 6.exit \n");
printf("\t\t\t Do you choose MENU : ");
scanf("%d", &choice);
if (choice == 1)
{
printf("\t\t\tPush element:");
scanf("%d", &e);
}
switch (choice)
{
case 1:
push(s, e);
break;
case 2:
pop(s);
break;
case 3:
display(s);
break;
case 4:
checkTop(s);
break;
case 5:
clearStack();
break;
}
} while (choice != 6);
}