Program of implementation of stack using arrays, Data Structure & Algorithms

Assignment Help:

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]);

}


Related Discussions:- Program of implementation of stack using arrays

Total impedent of the circuit, an electrical student designed a circuit in...

an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

Find the optimal solution - branch and bound algorithm, Consider the follow...

Consider the following 5-city traveling salesman problem. The distance between each city (in miles) is shown in the following table: (a) Formulate an IP whose solution will

Sorting, how to do a merge sorting

how to do a merge sorting

Write functions for both addition and subtraction, You will write functions...

You will write functions for both addition and subtraction of two numbers encoded in your data structure. These functions should not be hard to write. Remember how you add and subt

Binary tree creation, Binary tree creation struct NODE { struct N...

Binary tree creation struct NODE { struct NODE *left; int value; struct NODE *right; }; create_tree( struct NODE *curr, struct NODE *new ) { if(new->val

B-TREE and AVL tree diffrance, Explain process of B-TREE and what differen...

Explain process of B-TREE and what difference between AVL Tree Using Algorithms

Explain about the abstract data type, Explain about the Abstract data type ...

Explain about the Abstract data type Abstract data type (ADT) A set of values (the carrier set) and operations on those values

Question, A binary search tree is used to locate the number 43. Which of th...

A binary search tree is used to locate the number 43. Which of the following probe sequences are possible and which are not? Explain. (a) 61 52 14 17 40 43 (b) 2 3 50 40 60 43 (c)

Define the carrier set of the symbol abstract data type, Define the Carrier...

Define the Carrier set of the Symbol ADT Carrier set of the Symbol ADT is the set of all finite sequences of characters over Unicode characters set (Unicode is a standard char

Indexed sequential files, Indexed Sequential Files An index is inserted...

Indexed Sequential Files An index is inserted to the sequential file to provide random access. An overflow area required to be maintained to permit insertion in sequence. I

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd