Computer Science, asked by kumaridhavani, 6 hours ago

c program for push in stack​

Answers

Answered by MISSKOMAL
0

sorry I didn't understand your question okk

Answered by unknownRU
0

Hope it helps!

Mark me as Brainlist!

Program stack for push using array in c programming

#include<stdio.h>

#include<conio.h>

#define MAX 5

int a[MAX],top=-1;

void push();

void display();

int main()

{

int ch;

printf("1.push or insert\n");

printf("2.display\n");

printf("3.end program\n");

while(1){

printf("\nEnter choice");

scanf("%d",&ch);

switch(ch){

case 1:{

push();

break;

}

case 2:{

display();

break;

}

case 3:{

exit(0);}

default:

{

printf("wrong choice");

}}

}}

void push(){

int data;

if(top==MAX-1){

printf("\n overflow or stack is full");

}

else{

printf("enter element to be pushed:");

scanf("%d",&data);

top++;

a[top]=data;

}}

void display (){

int i;

if(top>0){

printf("elements:");

for(i=top;i>0;i--)

printf("\n %d",a[i]);

}

else{

printf("the stack is empty");

}}

Similar questions