Program 1: Write a C program to implement stack operations push and pop using array.
Program 2: Write a C program to implement stack operations push and pop using Linked List.
Program 3:Design an algorithm,using a stack to read five characters from a keyboard and display them in reverse order.
Program 4:Design an algorithm,using a stack,which will convert a decimal number to binary.
Program 5:Design an algorithm using a stack,which will test whether an input string is palindromic or not
Program 6:Write a C function to copy one stack to another assuming the stack is implemented using array
Program 7:Write a C function to copy one stack to another assuming the stack is implemented using Linked list
Write a C program to implement stack operations push and pop using Linked List.
ReplyDelete#include
ReplyDelete#include
#define SIZE 5
int top=-1;
int s[SIZE];
void push(int);
int pop();
void display();
void main()
{
int ch;
int item,y;
clrscr();
printf("menu");
printf("\t\n1.push");
printf("\t\n2.pop");
printf("\t\n3.display");
printf("\t\n4.exit");
do
{
printf("\n enter ur choice");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\n\t enter the elements");
scanf("%d",&item);
push(item);
break;
case 2:y=pop();
printf("\n\t deleted value is %d",y);
break;
case 3:display();
break;
case 4: exit(0);
break;
default :printf("invalid choice");
break;
}
}while(ch<=4);
}
void push(int item)
{
if(top==SIZE-1)
printf("\t stack overflow");
else
{
top++;
s[top]=item;
}
}
int pop()
{
int y;
if(top==-1)
printf("\n\t the stack is underflow");
else
{
y=s[top];
top--;
}
return y;
}
void display()
{
int i;
for(i=top;i>=0;i--)
printf("%d\t",s[i]);
}
wow!
Deletewap to implement stack using array,the array should ccontain names
ReplyDeleteKeep this going please, great job!
ReplyDeletemy web site: best registry cleaner
Also see my web page :: registry cleaner