Assignment 2 Dsa
Assignment 2 Dsa
#include<stdio.h>
#include<stdlib.h>
int main(){
node_type *Top=NULL;
int ch1;
char ch;
printf("Enter your choice");
do
{
printf("\n1. Push \n2. Pop \n3. Display ");
scanf("%d", &ch1);
switch (ch1)
{
case 1:
Rahul Bameta MCA 60 B
push(&Top);
break;
case 2:
pop(&Top);
break;
case 3:
display(&Top);
break;
}
printf("Do you want to continue press y or n to exit ");
scanf(" %c", &ch);
switch (ch)
{
case 'y':
continue;
case 'n':
return 0;
}
} while (ch == 'y');
}
}
int n;
printf("Enter the value to input ");
scanf("%d",&n);
p->info=n;
if(*tp==NULL){
p->next=NULL;
*tp=p;
}
else{
p->next=*tp;
*tp=p;
}
printf("The value %d is inserted \n",n);
}
#include<stdio.h>
#define MAX 3