`
//prog1
/Write a program to implement BookData using circular linked list with following
operations. Node has info like Book_id, Bname, price and author.
Insert from first
Insert from last
Insert by sorted Book_id
Delete by specific Bname
Delete from first
Delete from last
Display in ascending order by Bname
Display in descending order by Bname
Display list author wise/
include
include
include
struct linklist
{
int bid;
char bname[10];
int price;
char author[10];
struct linklist next;
}first=NULL,curr=NULL,new;
do
{
printf("\n\t****MENU*****");
printf("\nPress 1 For InsertFirst!");
printf("\nPress 2 For InsertLast!");
printf("\nPress 3 For insert by Book-Id!");
printf("\nPress 4 For Delete with name!");
printf("\nPress 5 For DeleteFirst!");
printf("\nPress 6 For Deletelast!");
printf("\nPress 7 For book list ascending!");
printf("\nPress 8 For book list descending!");
printf("\nPress 9 For list author wise!");
printf("\nPress 0 For Exit!");
printf("\n*****END*****");
printf("\nEnter Your Choice :");
scanf("%d",&ch);
switch(ch)
{
case 1: firstin();
display();
break;
case 2: lastin();
display();
break;
case 3: betweenin();
display();
break;
case 4: delbyname();
display();
break;
case 5: firstdel();
display();
break;
case 6: lastdel();
display();
break;
case 7: bnameasd();
break;
case 8: bnamedse();
break;
case 9: authorvis();
break;
case 0: break;
default:printf("\n\tWrong Choise!");
break;
}
}while(ch!=0);
void newadd()
{
new=(struct linklist*)malloc(sizeof(struct linklist));
printf("\n\tEnter Book ID : ");
scanf("%d",&new->bid);
printf("\n\tEnter Book Name : ");
scanf("%s",new->bname);
printf("\n\tEnter Book price : ");
scanf("%d",&new->price);
printf("\n\tEnter Book author : ");
scanf("%s",new->author);
new->next=NULL;
` //prog1 /Write a program to implement BookData using circular linked list with following operations. Node has info like Book_id, Bname, price and author. Insert from first Insert from last Insert by sorted Book_id Delete by specific Bname Delete from first Delete from last Display in ascending order by Bname Display in descending order by Bname Display list author wise/
include
include
include
struct linklist { int bid; char bname[10]; int price; char author[10]; struct linklist next; }first=NULL,curr=NULL,new;
typedef struct linklist *node;
int i; void display(); void firstin(); void lastin(); void betweenin(); void firstdel(); void lastdel(); void delbyname(); void newadd(); void bnameasd(); void bnamedse(); void authorvis();
void main() { int ch,size; node temp;
} void display() { if(first==NULL) { printf("\n\tLink-List Empty!"); return; } printf("\n\n"); curr=first; while(curr->next!=first) { printf("\n[ %x | %d | %s | %d | %s ]",curr,curr->bid,curr->bname,curr->price,curr->author); curr=curr->next; } printf("\n[ %x | %d | %s | %d | %s ]",curr,curr->bid,curr->bname,curr->price,curr->author); printf("\n\n"); }
void newadd() { new=(struct linklist*)malloc(sizeof(struct linklist)); printf("\n\tEnter Book ID : "); scanf("%d",&new->bid);
}
void firstin() { if(first==NULL) { newadd(); first=new; curr=new; first->next=first; } else { newadd(); curr=first; while(curr->next!=first) { curr=curr->next; } new->next=first; first=new; curr->next=first; } }
void lastin() {
}
void betweenin() { int po,c=0; node lab; newadd(); po=new->bid; if(first==NULL) { first=new; curr=new; first->next=first; }
}
void delbyname() { char str[10]; int f=0; node prev; node temp; if(first==NULL) { printf("\n\tLink-List Is Empty!"); return; }
}
void firstdel() { node temp; if(first==NULL) { printf("\n\tLink-List Is Empty!"); return; }
}
void lastdel() { node temp; node prev; if(first==NULL) { printf("\n\tLink-List Is Empty!"); return; } curr=first; while(curr->next!=first) { prev=curr; curr=curr->next; } temp=curr; prev->next=curr->next; printf("\n\t[ %d | %s | %d | %s ] Is deleted!",temp->bid,temp->bname,temp->price,temp->author); free(temp); }
void bnameasd() {
node index = NULL;
int tid,tprice; char tname[10],tauthor[10];
}
void bnamedse() {
node index = NULL;
int tid,tprice; char tname[10],tauthor[10];
}
void authorvis() {
node index = NULL;
int tid,tprice; char tname[10],tauthor[10];
}`