You are on page 1of 2

Assignment NO.

:-

/*WAP in C to perform push printf("\nInvalid


opration on stack */ choice!!");
}
#include <stdio.h> }
#include<stdlib.h> }

#define SIZE 4 void push ()


{
int top = -1, inp_array[SIZE]; int x;
void push(); if (top==SIZE - 1)
void show(); {
printf("\tOverflow!!");
int main() }
{ else
int choice; {
printf("\tEnter thr element
while (1) to be added onto the stack:");
{
printf("\nPerform operations scanf("%d", &x);
on the stack:"); top = top + 1;
printf("\t1.Push the inp_array[top] = x;
element\t2.Show\t3.End"); }
printf("\t\tEnter the }
choice:"); void show()
scanf("%d", &choice); {
switch (choice) if (top == -1)
{ {
case 1: printf("\tUnderflow!!");
push(); }
break; else
case 2: {
show(); printf("\nElements present
break; in the stack: \n");
case 3: for (int i = top; i >= 0; --i)
exit(0); printf("%d\t", inp_array[i]);
default: }
}
Assignment NO. :-

Output:-

You might also like