#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct student_details
{
char name[20];
int roll;
int dept;
struct student_details *next;
}student;
typedef struct library_details
{
int roll;
int dept;
int book_id;
struct library_details *next;
}library;
void print_info()
{
printf("\n 1. Enter student details \n");
printf("\n 2. Issue book \n");
printf("\n 3. Count book issued \n");
printf("\n 4. Exit \n");
}
int main()
{
int choice=0;
int roll,dept,book_id,bi;
char name[20];
student *sstart=NULL,*stmp,*sn;
library *lstart=NULL,*ltmp,*ln;
print_info();
while(choice != 4)
{
printf("\n Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1 : printf("\n Enter name, roll no., dept no : ");
scanf("%s %d %d",&name[20],&roll,&dept);
stmp = (student *)malloc(sizeof(student));
stmp->name[20]=name[20];
stmp->roll=roll;
stmp->dept=dept;
stmp->next=NULL;
if(sstart==NULL)
sstart=stmp;
else
{
sn=sstart;
while(sn->next != NULL)
sn=sn->next;
sn->next=stmp;
}
break;
case 2 : printf("\n Enter roll, dept and book_id : ");
scanf("%d %d %d",&roll,&dept,&book_id);
ltmp = (library *)malloc(sizeof(library));
ltmp->roll=roll;
ltmp->dept=dept;
ltmp->book_id=book_id;
ltmp->next=NULL;
if(lstart==NULL)
lstart=ltmp;
else
{
ln=lstart;
while(ln->next != NULL)
ln=ln->next;
ln->next=ltmp;
}
break;
case 3 : printf("\n Enter dept no and roll no : ");
scanf("%d %d",&dept,&roll);
bi=0;
ln=lstart;
while(ln!=NULL)
{
if(ln->roll == roll && ln->dept == dept)
{
bi++;
}
ln=ln->next;
}
printf("\n Total issued book to dept id %d and roll no %d : %d", dept,roll,bi);
break;
default : printf("WRONG INPUT !!!");
break;
}
}
return 0;
}
#include<conio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct student_details
{
char name[20];
int roll;
int dept;
struct student_details *next;
}student;
typedef struct library_details
{
int roll;
int dept;
int book_id;
struct library_details *next;
}library;
void print_info()
{
printf("\n 1. Enter student details \n");
printf("\n 2. Issue book \n");
printf("\n 3. Count book issued \n");
printf("\n 4. Exit \n");
}
int main()
{
int choice=0;
int roll,dept,book_id,bi;
char name[20];
student *sstart=NULL,*stmp,*sn;
library *lstart=NULL,*ltmp,*ln;
print_info();
while(choice != 4)
{
printf("\n Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1 : printf("\n Enter name, roll no., dept no : ");
scanf("%s %d %d",&name[20],&roll,&dept);
stmp = (student *)malloc(sizeof(student));
stmp->name[20]=name[20];
stmp->roll=roll;
stmp->dept=dept;
stmp->next=NULL;
if(sstart==NULL)
sstart=stmp;
else
{
sn=sstart;
while(sn->next != NULL)
sn=sn->next;
sn->next=stmp;
}
break;
case 2 : printf("\n Enter roll, dept and book_id : ");
scanf("%d %d %d",&roll,&dept,&book_id);
ltmp = (library *)malloc(sizeof(library));
ltmp->roll=roll;
ltmp->dept=dept;
ltmp->book_id=book_id;
ltmp->next=NULL;
if(lstart==NULL)
lstart=ltmp;
else
{
ln=lstart;
while(ln->next != NULL)
ln=ln->next;
ln->next=ltmp;
}
break;
case 3 : printf("\n Enter dept no and roll no : ");
scanf("%d %d",&dept,&roll);
bi=0;
ln=lstart;
while(ln!=NULL)
{
if(ln->roll == roll && ln->dept == dept)
{
bi++;
}
ln=ln->next;
}
printf("\n Total issued book to dept id %d and roll no %d : %d", dept,roll,bi);
break;
default : printf("WRONG INPUT !!!");
break;
}
}
return 0;
}
No comments:
Post a Comment