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

Darw a flowchart that inputs country someone is visiting, Regis lives in Br...

Regis lives in Brazil and frequently travels to USA, Japan and Europe. He wants to be able to convert Brazilian Reais into US dollars, European euros and Japanese yen. Conversion f

Efficiency of linear search, Efficiency of Linear Search How much numbe...

Efficiency of Linear Search How much number of comparisons is there in this search in searching for a particular element? The number of comparisons based upon where the reco

Write an algorithm to measure daily temperatures, A geography class decide ...

A geography class decide to measure daily temperatures and hours of sunshine each day over a 12 month period (365 days) Write an algorithm, using a flowchart that inputs tempera

Sorting algorithms, Sorting is significant application activity. Several so...

Sorting is significant application activity. Several sorting algorithms are obtainable. But, each is efficient for a specific situation or a specific kind of data. The choice of a

Determine about the unreachable code assertion, Determine about the unreach...

Determine about the unreachable code assertion An unreachable code assertion is an assertion that is placed at a point in a program that shouldn't be executed under any circum

Merging, Merging two sequence using CREW merge

Merging two sequence using CREW merge

Shortest path dijkstras algorithm, * Initialise d & pi* for each vertex ...

* Initialise d & pi* for each vertex v within V( g ) g.d[v] := infinity  g.pi[v] := nil g.d[s] := 0; * Set S to empty * S := { 0 }  Q := V(g) * While (V-S)

Union & intersection of two linklist, how to write an algorithm for unions ...

how to write an algorithm for unions & intersection of two linklists?

Matrix stored in memory, Method to measure address of any element of a matr...

Method to measure address of any element of a matrix stored in memory. Let us consider 2 dimensional array a of size m*n further consider that the lower bound for the row index

B-tree of minimum degree t can maximum pointers in a node, A B-tree of mini...

A B-tree of minimum degree t can maximum pointers in a node T pointers in a node.

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