Batch - B Practical Test Question

Batch - B Practical Test Question
Batch - B Practical Test Question

Skeleton of Stack Program using Linked List

#include<stdio.h>
#include<memory.h>
#include<stdlib.h>

//Data Structure Declaration
struct Element
{
int value;
struct Element *next;
};

struct Element *TOS=NULL,*temp=NULL; 
//You are free to create more pointers, if needed

//Stack Size, Show Overflow for > 5
int SIZE=5;

//Function Declaration
void push(int);
void pop();
void peek();
void peep(int );
void displayStack();
int countElement();

//Main Function
int main()
{
int choice,postion,value;
//You are free to create more variable, if needed
do
{
system("cls"); // To clear the screen
printMenu();
printf("\nEnter Your Choice : ");
scanf("%d",&choice);

switch(choice)
{
case 1:

break;

case 2:

break;

case 3:

break;

case 4:

break;

case 5:

break;

case 6:

break;

case 7:

break;
default:
printf("Thanks for Using Stack Program");
}

getch(); //To stop output on Screen

}while(choice>0 && choice<7);
return 0;
}


//Function Implementation
void printMenu()
{
printf("\n==============================");
printf("\n    STACK OPERATION MENU");
printf("\n==============================");
printf("\n     1 - PUSH");
printf("\n     2 - POP");
printf("\n     3 - PEEK");
printf("\n     4 - PEEP");
printf("\n     5 - DISPLAY");
printf("\n     6 - COUNT NO OF ELEMENT");
printf("\n     7 - EXIT");
printf("\n==============================");
}

void push(int value)
{
//Check Overflow condition Max Size = 5
}

void pop()
{
//Check underflow condition as POP not possible with Empty Stack
}

void peek()
{
//Display Value of TOS
}

void peep(int pos)
{
//Display Value of element at given pos
}

void displayStack()
{
//display all element of Stack as LL
}

int countElement()
{
//return the no of element in stack, can be used in pop() and push()
}

Comments