Friday, July 12, 2013

DFS(lab) Book Library Application Codding (273 Lines)

Hello Friends, I have created application which ma'am was given in our lab test. So, its still not in full version you can modify in this codding with your own functions. Execute it ....

/*Create one Book Library  application which have Library Functions. A  program must be perform on given functions

1. Search Student
2. Search Book
3. Issue Book
4. Manipulate

*/
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>    //<--- This header file used for exit(0); function

void getstudentdata();
void getbookdata();
void searchstudent();
void searchbook();
void issuebook();
void studentdata();
void bookdata();

struct student
{
char name[20],father[20];
int age,id,issue;
}s[10];

struct book
{
char name[20],author[20];
int price,ip;
}b[10];


void main()
{
int search;
clrscr();

printf("\n\n\tBook Library Application");

printf("\n\n\tPlease, First Enter all data");

printf("\n\tLets Start from Student Details\n\n");

getstudentdata();

printf("\n\tNow, Enter Book Details\n\n");

getbookdata();

cc: 
getch();
clrscr();

printf("\n\n\nEnter 1 for Search Student\nEnter 2 for Search Book\nEnter 3 for Issue Book\nEnter 4 for Display Student's Details\nEnter 5 for Book Details\n\nEnter 0 for Exit");
scanf("%d",&search);

switch(search)
{
case 1:
{
searchstudent();
goto cc;
}
case 2:
{
searchbook();
goto cc;
}
case 3:
{
issuebook();
goto cc;
}
case 4:
{
studentdata();
goto cc;
}
case 5:
{
bookdata();
goto cc;
}
case 0:
{
exit(0);
}
default:
{
printf("\n\n\tInvalid Choice");
goto cc;
}
}
}
void getstudentdata()
{
int i=0;

while(i<2)
{
fflush(stdin);

printf("\n\nEnter ID NO: ");
scanf("%d",&s[i].id);

fflush(stdin);

printf("Enter Name :");
gets(s[i].name);

printf("Enter Father Name :");
gets(s[i].father);

fflush(stdin);

printf("Enter Age :");
scanf("%d",&s[i].age);
i++;
}
}

void getbookdata()
{
int i=0;

while(i<2)
{
fflush(stdin);

printf("\n\nEnter IP NO: ");
scanf("%d",&b[i].ip);

fflush(stdin);

printf("Enter Book Name :");
gets(b[i].name);

printf("Enter Author Name :");
gets(b[i].author);

fflush(stdin);

printf("Enter Price :");
scanf("%d",&b[i].price);
i++;
}
}
void searchstudent()
{
int id=50,i=0,flag=0;

printf("\n\nEnter Student ID:");
scanf("%d",&id);

while(i<2)
{
if(id==s[i].id)
{
printf("\n\nID : %d\nName : %s\nFather Name :%s\nAge :%d\nIssued Books",s[i].id,s[i].name,s[i].father,s[i].age,s[i].issue);
flag=1;
}
i++;
}

if(flag==0)
{
printf("\n\nStudent doesn't Found !");
}
}

void searchbook()
{
int ip,i=0,flag=0;

printf("\n\nEnter Book IP:");
scanf("%d",&ip);

while(i<2)
{
if(ip==b[i].ip)
{
printf("\n\nIP : %d\nName : %s\nAuthor Name :%s\nPrice :%d",b[i].ip,b[i].name,b[i].author,b[i].price);
flag=1;
}
i++;
}
if(flag==0)
{
printf("\n\nBook doesn't Found !");
}
}
void issuebook()
{
int id,ip,flag=0,flagg=0,i=0;
s[i].issue=0;
aa:
printf("\n\nEnter Student ID, who want to issue book");
scanf("%d",&id);
while(i<2)
{
if(id==s[i].id)
{
flag=1;
}
i++;
}

if(flag==0)
{
printf("Student doesn't found in this ID");
goto aa;
}
bb:
printf("Which Book want to Issue? IP :");
scanf("%d",&ip);
i=0;
while(i<2)
{
if(ip==b[i].ip)
{
flagg=1;
}
i++;
}
if(flagg==0)
{
printf("Book doesn't found in this IP");
goto bb;
}
i=0;
while(i<2)
{
if(id==s[i].id)
{
s[i].issue++;
printf("\nBook Issued");
}
i++;
}
}
void studentdata()
{
int i=0;

while(i<2)
{
printf("\n\nID : %d\nName : %s\nFather Name :%s\nAge :%d\nIssued Books",s[i].id,s[i].name,s[i].father,s[i].age,s[i].issue);
i++;
}
}
void bookdata()
{
int i=0;

while(i<2)
{
printf("\n\nIP : %d\nName : %s\nAuthor Name :%s\nPrice :%d",b[i].ip,b[i].name,b[i].author,b[i].price);
i++;
}
}

No comments:

Post a Comment