Skip to main content

Posts

Showing posts from August 3, 2017

LINKED STACK IN PUSH, POP, PEEP & UPDATE OPERATIONS

CODING: #include<stdio.h> #include<conio.h> #include<malloc.h> struct stack { int no; struct stack *next; }; struct stack *top=NULL; struct stack *push(struct stack *,int); struct stack *pop(struct stack *); struct stack *update(struct stack *); struct stack *display(struct stack *); int peep(struct stack *); void main() { int val,ch; clrscr(); do {  printf("\n\nS E L E C T  O P E R A T I O N");  printf("\n1.PUSH");  printf("\n2.POP");  printf("\n3.PEEP");  printf("\n4.UPDATE");  printf("\n5.DISPLAY");  printf("\n6.EXIT");  printf("\nEnter The option:");  scanf("%d",&ch);  switch(ch)  {  case 1:  printf("\nEnter the number to be pushed on to the stack:");  scanf("%d",&val);  top=push(top,val);  break;  case 2:  top=pop(top);  break;  case 3:  val=peep(top);  printf("\nThe value stored at the top of the st

STACK ARRAY IN PUSH, POP, PEEP & UPDATE OPERATIONS

#include<stdio.h> #include<conio.h> #define max 10 int  st[max],top=-1; void push(int st[],int val); int  pop(int st[]); int  peep(int st[]); int  update(int st[]); void display(int st[]); void main() { int  val,ch; clrscr(); do { printf("\nS E L E C T  O P E R A T I O N\n"); printf("\n1.PUSH"); printf("\n2.POP"); printf("\n3.PEEK"); printf("\n4.UPDATE"); printf("\n5.OPEN"); printf("\n6.EXITE"); printf("\nEnter The option:");  scanf("%d",&ch); switch(ch) { case 1:  printf("Enter the number to be pushed on to the stack:");  scanf("%d",&val);  push(st,val);  break; case 2:  val=pop(st);  printf("\nThe Value deleted from the stack is:%d",val);  break; case 3:  val=peep(st);  printf("\nThe Value stored at the top of the stack is:%d",val);  break; case 4:  val=update(st);  printf("\nThe value is u