Lovely institute of engineering and Computer application b.tech-m.tech(dual degree)- cse
mini project onimplementation of doubly linked list using graphics
submitted t0-
submitted by-
miss deepika sukhija
AJAY KUMAR roll n0-
rk2r13a15
regn no11009446
Acknowledgment I have created and nurtured this project for last two months. The resources like internet, books have contributed in materializing this project. This project bears an imprint of many people. I acknowledge the magnanimous support and guidance of these resources in carrying out this project work. I also wish to express heartfelt gratitude to my mam and my friends who have rendered their generous assistance. It would be injustice if I don’t thank my friends who helped me during this project.
Contents1. Introduction of link list 2. Doubly link list 3. Functions of graphics a) getcolor function b) cleardevice function c) getmaxcolor function d) getmaxy function e) setcolor function f) putpixel function g) Source code
4. references
Link listIn computer science, science, a linked list is a data structure consisting of a group of nodes of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence .
Doubly link listIn computer science, science, a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. nodes. Each node contains two fields, fields, called links, that are references to the previous and to the next node in the sequence of nodes. The beginning and ending nodes' previous and next links, respectively, point to some kind of terminator, typically a sentinel node or null or null,, to facilitate traversal of the list. If there is only one sentinel node, then the list is circularly linked via the sentinel node. It can be conceptualized as two singly linked lists formed from the same data items, but in opposite sequential orders.
The two node links allow traversal of the list in either direction. While adding or removing a node in a doubly linked list requires changing more links than the same operations on a singly linked list, the operations are simpler and potentially more efficient (for nodes other than first nodes) because there is no need to keep track of the previous node during traversal or no need to traverse the list to find the previous node, so that its link can be modified. Now we have to implement the doubly linked list using graphics but firstly I would like to explain explain about graphics and some of the graphics graphics functions.
Functions of graphics’C graphics using graphics.h functions or WinBGIM (Windows 7 ) can be used to draw different shapes, display text in different fonts, change color and many more. Using functions of graphics.h in turbo c compiler you can make graphics programs, animations, projects and games.You can draw circles, lines, rectangles, bars and many other geometrical geometrical figures. You can change change their colors using the available functions and fill them. Following is a list of functions of graphics.h header file. Every function is discussed with the arguments it needs, its description, possible errors while using that function and a sample c graphics program with its output. output.
SOME of c graphics functions getcolor functionfunctiongetcolor function returns the current drawing color. Declaration : int getcolor( ); e.g. a = getcolor( ); // a is an integer variable if current drawing color is WHITE then a will be 15.
Cleardevice function-
Declaration :- void cleardevice(); cleardevice function clears the screen in graphics mode and sets the current position to (0,0). Clearing Clearing the screen consists of filling filling the screen with current current background color.
Getmaxcolor functiongetmaxcolor function returns maximum color value for current graphics mode and driver. Total number of colors available for current graphics mode and driver are ( getmaxcolor() + 1 ) as color numbering starts from zero. Declaration :- int getmaxcolor( );
Getmaxy function – getmaxy function returns the maximum Y coordinate for current graphics mode and driver. Declaration :- int getmaxy();
Setcolor functionDeclaration :- void setcolor(int color); In Turbo Graphics each color is assigned a number. Total 16 colors are available. Strictly speaking number of available colors depends on current graphics mode and driver.For Example :- BLACK is assigned 0, RED is assigned 4 etc. setcolor function is used to change the current drawing color.e.g. setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE.
Putpixel function putpixel function plots a pixel at location location (x, y) of specified color. color. Declaration :- void putpixel(int x, int y, int color);
For example if we want to draw a GREEN color pixel at (35, 45) then we will write putpixel(35, 35, GREEN); in our c program, putpixel function can be used to draw circles, lines and ellipses using various algorithms.
Source codeThis program maintains a employee’s record using doubly linked list. It involves simple graphics and a login me nu nu where I had used file hadling hadling to maintain a record og 3 user’s name and their password . so before running the program kindly create a text document in d:\with the name LOGIN.txt.In this just add the following data: Ceo computer Manager mouse Admin hello123 i.e only 3 persons can be allowed to login with their respective password PROGRAM#include
#include #include #include #include #include #include struct login
/* Used for records of authorised login */
{ char username[30]; char password[15];
}; struct login l[3];/* as authorised users are ceo,manager and administrator */
struct employee {
/* structure of Double linked list */
int employee_no; char employee_name[20]; float grosspay; char designation[10]; designation[10]; int age; char sex[6]; struct employee *nextptr; struct employee *previousptr; };
typedef struct employee employee; /*********************** /*********************************FUN **********FUNCTION CTION PROTOTYPE**************** PROTOTYPE***************************/ ***********/ void border_margin(void); border_margin(void);
/*
CREATING BORDER
void printmain(void);
/*
void new_employee();
/* APPEND FUNCTIONS
void display(employee *);
/* PRINTING THE RECORDS
void delete_employee(); void update();
PRINTING MAIN
*/
*/ */ */
/* DELETING THE RECORDS
/* TO MODIFY FUNCTION
void search_employee(int); search_employee(int); /* SEARCHING RECORDS
*/
*/ */
void printdetail(void); printdetail(void); employee *getnode(int);
/* FOR CREATING NEW NODES (MALLOC) */
employee *head=NULL;
/* INITIALLY LINKED LIST IS EMPTY */
employee *tail=NULL;
/*********************** /************************************ ************************** ************************** ************************** ****************/ ***/
int k,i,j,count=0; char ans,choice,choice1,choice2,choice3; ans,choice,choice1,choice2,choice3; /* for accessing menu */ void main() {
/* request auto detection */ int gdriver = DETECT, gmode, errorcode; int maxx, maxy,i,count=0,flag=0; /* initialize graphics, local variables */ initgraph(&gdriver, initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
/* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* If an error occurred as grOK means no error */ { clrscr(); printf("Graphics Error Detected : %s\n", grapherrormsg(errorcode)); printf("Press any key to halt...."); printf("\nThank You.\t\n- Comp. Science Students.\n Students.\n Batch : C-5 and C6"); printf("\n Jaypee University Of Of Information Technology Technology , Waknaghat"); getch(); exit(0); /* Terminate with with an error code */ }
maxx = getmaxx(); maxy = getmaxy(); setcolor(YELLOW); setcolor(YELLOW);
/* select drawing color
setfillstyle(SOLID_FILL,BLUE); setfillstyle(SOLID_FILL,BLUE); /*
select fill color
*/ */
rectangle(0, 0, maxx, maxy); /* draw a border around the screen */ bar(0,0,maxx,maxy);
/* for painting background blue */
settextstyle(5,0,6); outtextxy(130,50,"Employee outtextxy(130,50,"Employee Records"); outtextxy(250,130,"Of outtextxy(250,130,"Of A"); outtextxy(210,210,"Company"); settextstyle(2,0,7); outtextxy(120,300,"A outtextxy(120,300,"A DOUBLY LINKED LIST IMPLEMENTATION"); settextstyle(2,0,4); outtextxy(100,360,"PRESS outtextxy(100,360,"PRESS A KEY TO CONTINUE ...."); music(3); /********************** /********************** END OF INTRO SCREEN ************************** ************************************** ************//
cleardevice(); /* CLEARS THE SCREEN */ settextstyle(0,0,0); setfillstyle(SOLID_FILL,BLUE); setfillstyle(SOLID_FILL,BLUE); /* select fill color
*/
rectangle(0, 0, maxx, maxy); /* draw a bborder order around the screen */ bar(0,0,maxx,maxy);
/* for painting background blue
setcolor(YELLOW); outtextxy(25,30,"ÿ");outtextxy(30,30,"Î"); outtextxy(30,25,"º"); for(i=35;i<=450;i+=5)
*/
outtextxy(30,i,"º"); for(i=35;i<=600;i+=5) outtextxy(i,30,"ÿ"); settextstyle(5,0,5);outtextxy(90,50 settextstyle(5,0,5);outtextxy(90,50,"About ,"About the Project"); char str1[70]={"Programmers : Students Of Batch C5 & C6"}; char str2[30]={"Platform : Turbo C++ IDE"}; char str3[30]={"Duration str3[30]={"Duration : Approx 10 Days"}; char str4[34]={"Instructor str4[34]={"Instructor : Mr.Satish Chandra"}; Chandra"}; char str5[30]={"Contacts str5[30]={"Contacts : +919816184767"}; +919816184767"}; char str6[30]={"®® Press A Key To Continue ¯¯"}; int j=10,k=12; settextstyle(0,0,0);
// LOGIN MENU cleardevice(); logi: /* label to return in case case access is denied */ setfillstyle(SOLID_FILL,BLUE); setfillstyle(SOLID_FILL,BLUE); /* select fill color
*/
rectangle(0, 0, maxx, maxy); /* draw a bborder order around the screen */ bar(0,0,maxx,maxy);
/* for painting background blue
settextstyle(5,0,5); setcolor(YELLOW); outtextxy(110,90,"®® outtextxy(110,90,"®® Login Menu ¯¯"); settextstyle(0,0,0); k = 155; outtextxy(150,220,"É"); for(i=0;i<=1050;i+=4)
*/
{ outtextxy(k,220,"ÿ"); k++; } outtextxy(424,220,"»");outtextxy(150,225,"º"); outtextxy(150,230,"º");outtextxy(150,235,"º"); outtextxy(150,240,"º");outtextxy(150,245,"Ì"); outtextxy(424,225,"º");outtextxy(424,230,"º"); outtextxy(424,235,"º");outtextxy(424,240,"º"); outtextxy(424,245,"¹");outtextxy(150,250,"º"); outtextxy(150,255,"º");outtextxy(150,260,"º"); outtextxy(150,265,"È");outtextxy(424,250,"º"); outtextxy(424,255,"º");outtextxy(424,260,"º"); outtextxy(424,265,"¼");outtextxy(1 outtextxy(424,265,"¼");outtextxy(160,235,"USERNAME 60,235,"USERNAME : "); outtextxy(160,255,"PASSWORD outtextxy(160,255,"PASSWORD : "); k=155; char str7[15],str8[10],character; str7[15],str8[10],character; for(i=0;i<=1050;i+=4) { outtextxy(k,245,"ÿ"); k++; } k=155; for(i=0;i<=1050;i+=4) { outtextxy(k,265,"ÿ"); k++; } gotoxy(31,15);gets(str7);
i=0;k=31; do {
character=getch(); /* These thing is done so that password is not visible*/ gotoxy(k,17) ;printf("*"); str8[i]=character; k++; i++;
}while(character != '.'); i--; str8[i]='\0'; /* NOW COMING THE FILE HANDLING */ FILE *fp; i=0;flag=0; fp=fopen("d:\LOGIN.txt","r+");/* fp=fopen("d:\LOGIN.txt","r+");/* login.txt already contains the username n paswd*/ while(fscanf(fp,"%s\t%s\n",l[i].username,l[i].pa while(fscanf(fp,"%s\t%s\n",l[i].username,l[i].password)!= ssword)!= EOF) { if(strcmp(str7,l[i].username)==0 if(strcmp(str7,l[i].username)==0 && strcmp(str8,l[i].password)==0) strcmp(str8,l[i].password)==0) { flag=1; } i++; } settextstyle(10,0,1); if(flag==0) { outtextxy(140,275,"®® outtextxy(140,275,"®® ACCESS DENIED ¯¯ ");music(1);music(1); ");music(1);music(1); outtextxy(140,320,"PRESS outtextxy(140,320,"PRESS A KEY TO CONTINUE..."); getch();
count++; if(count< 3) { goto logi; /* i m giving giving 3 chances in case user user make any mistakes */ } else exit(0);/* go out of program as access is denied */ } else { outtextxy(140,275,"ACCESS GRANTED ¯ ¯ ¯");music(1);music(1); outtextxy(140,320,"PRESS outtextxy(140,320,"PRESS A KEY TO CONTINUE..."); } fclose(fp); getch(); closegraph(); restorecrtmode();
/*********************** /************************************ ************************** ************************** ************************** ******************** ******* Now coming to main menu if access granted
int key; main: printmain(); /* WILL PRINT THE MAIN MENU */ gotoxy(45,21);choice=getche(); switch(choice) { case '1':
*/
new_employee(); /* APPENDING APPENDING THE RECORD */ */ getch(); goto main;
case '2': clrscr(); display(head); /* PRINTING THE RECORDS */ goto main; case '3': delete_employee(); goto main;
case '4': update(); /* MODIFYING THE RECORDS */ goto main;
case '5': clrscr(); border_margin(); gotoxy(25,6);cprintf("R gotoxy(25,6);cprintf("R E C O R D S E A R C H"); gotoxy(5,8);cprintf("ENTER gotoxy(5,8);cprintf("ENTER THE EMPLOYEE NUMBER WHICH IS TO BE UPDATED : "); gotoxy(57,8);scanf("%d",&key); search_employee(key); getch(); goto main;
case '6': border_margin(); gotoxy(25,11);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,11);cprintf("ÿ"); gotoxy(k,11);cprintf("ÿ"); k++; } gotoxy(50,11);cprintf("»"); gotoxy(25,12);cprintf("º
º");
gotoxy(25,13);cprintf("È");gotoxy gotoxy(25,13);cprintf("È");gotoxy(50,13);cprintf("¼"); (50,13);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,13);cprintf("ÿ"); gotoxy(k,13);cprintf("ÿ"); k++; } gotoxy(32,9);cprintf("QUITING gotoxy(32,9);cprintf("QUITING ...."); .. .."); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ");delay(50); gotoxy(k,12);cprintf("ÿ");delay(50); k++; } gotoxy(22,19);textcolor(YELL gotoxy(22,19);textcolor(YELLOW OW + BLINK); cprintf("PRESS A KEY TO RETURN TO WINDOWS"); gotoxy(30,17);textcolor(YELL gotoxy(30,17);textcolor(YELLOW);cprintf("B OW);cprintf("B Y E B Y E !!");
gotoxy(24,79); getch(); break;
default: goto main;
} }
void new_employee() {
clrscr(); border_margin(); employee *emp; textcolor(YELLOW); gotoxy(25,3);cprintf("E gotoxy(25,3);cprintf("E N T E R I N G R E C O R D"); printdetail(); if(head==NULL&&tail==NULL) { count++; emp=getnode(count); head=emp; tail=emp; emp->previousptr=NULL; emp->nextptr=NULL; }
else { count++; emp=getnode(count); emp->previousptr=tail; tail->nextptr=emp; emp->nextptr=NULL; tail=emp; }
} void display(employee *temp) { if(head==NULL) if(head==NULL) /* EMPTY LINKED LINKED LIST */ { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; } gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º NO RECORDS AVAILABLE º"); gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++)
{ gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } } else { if(temp==head) do { clrscr(); border_margin(); gotoxy(25,5);cprintf("P gotoxy(25,5);cprintf("P R I N T I N G R E C O R D"); printdetail(); gotoxy(20,7);cprintf("%d",temp->employee_no); gotoxy(20,9);puts(temp->employee_name); gotoxy(20,11);cprintf("%f",temp->gros gotoxy(20,11);cprintf("%f",temp->grosspay);fflush(stdin spay);fflush(stdin); ); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);cprintf("%d",temp->age) gotoxy(20,15);cprintf("%d",temp->age);fflush(stdin); ;fflush(stdin); gotoxy(20,17);puts(temp->sex);
gotoxy(25,20);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,20);cprintf("ÿ"); gotoxy(k,20);cprintf("ÿ"); k++; } gotoxy(50,20);cprintf("»"); gotoxy(25,21);cprintf("º gotoxy(25,21);cprintf("º HIT KEY FOR NEXT RECORDº");
gotoxy(25,22);cprintf("È");gotoxy gotoxy(25,22);cprintf("È");gotoxy(50,22);cprintf("¼"); (50,22);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,22);cprintf("ÿ"); gotoxy(k,22);cprintf("ÿ"); k++; } getch(); temp=temp->nextptr;
}while(temp!=NULL); } } void delete_employee() { int key,flag; employee *temp; temp=head; if(head==NULL) if(head==NULL) /* EMPTY LINKED LINKED LIST */ { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; }
gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º NO RECORDS AVAILABLE º"); gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } goto last; } else { clrscr(); border_margin(); gotoxy(10,7);cprintf("ENTER gotoxy(10,7);cprintf("ENTER THE EMPLOYEE NUMBER YOU WANT TO DELETE : "); gotoxy(55,7);scanf("%d",&key); border_margin(); gotoxy(25,11);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,11);cprintf("ÿ"); gotoxy(k,11);cprintf("ÿ"); k++; } gotoxy(50,11);cprintf("»"); gotoxy(25,12);cprintf("º
º");
gotoxy(25,13);cprintf("È");gotoxy gotoxy(25,13);cprintf("È");gotoxy(50,13);cprintf("¼"); (50,13);cprintf("¼"); k=26;
for(i=1;i<=24;i++) { gotoxy(k,13);cprintf("ÿ"); gotoxy(k,13);cprintf("ÿ"); k++; } gotoxy(25,9);cprintf("SEARCHING gotoxy(25,9);cprintf("SEARCHING FOR RECORDS ..."); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ");delay(50); gotoxy(k,12);cprintf("ÿ");delay(50); k++; } gotoxy(22,19);textcolor(YELLOW); cprintf("PRESS A KEY TO RETURN TO CONTINUE ..."); gotoxy(28,17);cprintf("SEARCHING gotoxy(28,17);cprintf("SEARCHING COMPLETE"); getch();
/* traverse the entire linked list */ while(temp!=NULL) { if(temp->employee_no if(temp->employee_no == key) { flag++; if(temp==head) /* ifif node node is first */ { head=head->nextptr; head->previousptr=NULL; } else { if(temp->nextptr==NULL) if(temp->nextptr==NULL) /* if node node is last */ temp->previousptr->nextptr=NULL;
else { temp->previousptr->nextptr temp->previousptr->nextptr = temp->nextptr; temp->nextptr->previousptr temp->nextptr->previousptr = temp->previousptr; temp->previousptr; } free(temp); } } temp=temp->nextptr; } } if(flag==0) { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; } gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º
NO RECORDS FOUND º");
gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++;
} getch(); } if(flag==1) { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; } gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º
RECORD DELETED
º");
gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } getch(); } last: getch(); } void update()
{ int choice; char str[30]; char f; employee *temp; temp=head; if(head==NULL) if(head==NULL) /* EMPTY LINKED LINKED LIST */ { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; } gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º NO RECORDS AVAILABLE º"); gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } } else { clrscr(); border_margin();
gotoxy(25,3);cprintf("R gotoxy(25,3);cprintf("R E C O R D U P D A T E"); gotoxy(5,5);cprintf("ENTER gotoxy(5,5);cprintf("ENTER THE EMPLOYEE NUMBER WHICH IS TO BE UPDATED : "); gotoxy(57,5);scanf("%d",&choice); if(choice > count) { clrscr(); border_margin(); gotoxy(10,10);cprintf("EMPLOYEE gotoxy(10,10);cprintf("EMPLOYEE NO NOT FOUND"); getch(); goto last; } again: gotoxy(5,10);cprintf("1. gotoxy(5,10);cprintf("1. NAME ");gotoxy(5,11);cprintf("2. ");gotoxy(5,11);cprintf("2. GROSS PAY"); gotoxy(5,12);cprintf("3. gotoxy(5,12);cprintf("3. DESIGNATION");gotoxy(5,13);cprint DESIGNATION");gotoxy(5,13);cprintf("4. f("4. AGE"); gotoxy(5,14);cprintf("5. gotoxy(5,14);cprintf("5. SEX"); gotoxy(5,16);cprintf("ENTER gotoxy(5,16);cprintf("ENTER THE FIELD YOU WANT TO EDIT : "); gotoxy(41,16);fflush(stdin);f=getch(); switch(f) { case '1': fflush(stdin); gotoxy(5,18);cprintf("ENTER gotoxy(5,18);cprintf("ENTER NEW NAME : ");gets(str); while(choice!=temp->employee_no) temp=temp->nextptr; clrscr(); printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); strcpy(temp->employee_name,str);
gotoxy(20,9);printf("%s",temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex); break; case '2': float gp; fflush(stdin); gotoxy(20,18);cprintf("ENTER gotoxy(20,18);cprintf("ENTER NEW GROSS : ");scanf("%f",&gp); while(choice!=temp->employee_no) temp=temp->nextptr; clrscr(); printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); temp->grosspay = gp; gotoxy(20,9);printf("%s",temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex); break; case '3': fflush(stdin); gotoxy(20,18);cprintf("ENTER gotoxy(20,18);cprintf("ENTER NEW DESIGNATION : ");gets(str); while(choice!=temp->employee_no)
temp=temp->nextptr; clrscr(); printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); strcpy(temp->designation,str); gotoxy(20,9);printf("%s",temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex); break; case '4': int gp1; fflush(stdin); gotoxy(20,18);cprintf("ENTER gotoxy(20,18);cprintf("ENTER NEW AGE : ");scanf("%d",&gp1); while(choice!=temp->employee_no) temp=temp->nextptr; clrscr(); printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); temp->age = gp1; gotoxy(20,9);printf("%s",temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex);
break; case '5': fflush(stdin); gotoxy(20,18);cprintf("ENTER gotoxy(20,18);cprintf("ENTER NEW SEX : ");gets(str); while(choice!=temp->employee_no) temp=temp->nextptr; clrscr(); printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); strcpy(temp->sex,str); gotoxy(20,9);printf("%s",temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);puts(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex); break; default: goto again; } gotoxy(25,20);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,20);cprintf("ÿ"); gotoxy(k,20);cprintf("ÿ"); k++; } gotoxy(50,20);cprintf("»");
gotoxy(25,21);cprintf("º RECORD UPDATED º"); gotoxy(25,22);cprintf("È");gotoxy gotoxy(25,22);cprintf("È");gotoxy(50,22);cprintf("¼"); (50,22);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,22);cprintf("ÿ"); gotoxy(k,22);cprintf("ÿ"); k++; } } last: getch(); } employee *getnode(int count) { employee *nodeptr; nodeptr=(employee nodeptr=(employee *)malloc(sizeof(employee)); *)malloc(sizeof(employee)); nodeptr->employee_no=count; gotoxy(20,7);printf("%d",nodeptr->e gotoxy(20,7);printf("%d",nodeptr->employee_no);fflush mployee_no);fflush(stdin); (stdin); gotoxy(20,9);gets(nodeptr->employee_name); gotoxy(20,11);scanf("%f",&nodeptr->gro gotoxy(20,11);scanf("%f",&nodeptr->grosspay);fflush(std sspay);fflush(stdin); in); gotoxy(20,13);gets(nodeptr->designation); gotoxy(20,15);scanf("%d",&nodeptr->age gotoxy(20,15);scanf("%d",&nodeptr->age);fflush(stdin); );fflush(stdin); gotoxy(20,17);gets(nodeptr->sex); gotoxy(25,20);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,20);cprintf("ÿ"); gotoxy(k,20);cprintf("ÿ"); k++;
} gotoxy(50,20);cprintf("»"); gotoxy(25,21);cprintf("º gotoxy(25,21);cprintf("º RECORD ENTRY SUCESSFUL º"); º "); gotoxy(25,22);cprintf("È");gotoxy gotoxy(25,22);cprintf("È");gotoxy(50,22);cprintf("¼"); (50,22);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,22);cprintf("ÿ"); gotoxy(k,22);cprintf("ÿ"); k++; } nodeptr->previousptr=NULL; nodeptr->nextptr=NULL; return nodeptr; } void search_employee(int key) { employee *temp; clrscr(); border_margin(); gotoxy(25,11);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,11);cprintf("ÿ"); gotoxy(k,11);cprintf("ÿ"); k++; } gotoxy(50,11);cprintf("»"); gotoxy(25,12);cprintf("º
º");
gotoxy(25,13);cprintf("È");gotoxy gotoxy(25,13);cprintf("È");gotoxy(50,13);cprintf("¼"); (50,13);cprintf("¼");
k=26; for(i=1;i<=24;i++) { gotoxy(k,13);cprintf("ÿ"); gotoxy(k,13);cprintf("ÿ"); k++; } gotoxy(32,9);cprintf("SEARCHING..."); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ");delay(50); gotoxy(k,12);cprintf("ÿ");delay(50); k++; } gotoxy(22,19);textcolor(YELLOW); cprintf("PRESS A KEY TO RETURN TO CONTINUE >>"); gotoxy(28,17);cprintf("SEARCHING gotoxy(28,17);cprintf("SEARCHING COMPLETE"); getch(); temp=head; int flag=0; if(temp==NULL) /* LINKED LIST IS EMPTY */ { clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; }
gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º NO RECORDS AVAILABLE º"); gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } music(1);music(1); goto last; } while(temp!=NULL) { if(temp->employee_no==key) { flag++; printdetail(); gotoxy(20,7);printf("%d",temp->employee_no); gotoxy(20,9);puts(temp->employee_name); gotoxy(20,11);printf("%f",temp->grosspay); gotoxy(20,13);gets(temp->designation); gotoxy(20,15);printf("%d",temp->age); gotoxy(20,17);puts(temp->sex); gotoxy(25,20);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,20);cprintf("ÿ"); gotoxy(k,20);cprintf("ÿ"); k++;
} gotoxy(50,20);cprintf("»"); gotoxy(25,21);cprintf("º gotoxy(25,21);cprintf("º
RECORD FOUND
º");
gotoxy(25,22);cprintf("È");gotoxy(5 gotoxy(25,22);cprintf("È");gotoxy(50,22);cprintf("¼"); 0,22);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,22);cprintf("ÿ"); gotoxy(k,22);cprintf("ÿ"); k++; } music(1);music(1); } temp=temp->nextptr; } if(flag==0) { clrscr(); border_margin(); clrscr(); border_margin(); gotoxy(25,10);cprintf("É"); k=26; for(i=1;i<=24;i++) { gotoxy(k,10);cprintf("ÿ"); gotoxy(k,10);cprintf("ÿ"); k++; } gotoxy(50,10);cprintf("»"); gotoxy(25,11);cprintf("º gotoxy(25,11);cprintf("º RECORDS NOT FOUND º");
gotoxy(25,12);cprintf("È");gotoxy gotoxy(25,12);cprintf("È");gotoxy(50,12);cprintf("¼"); (50,12);cprintf("¼"); k=26; for(i=1;i<=24;i++) { gotoxy(k,12);cprintf("ÿ"); gotoxy(k,12);cprintf("ÿ"); k++; } } last: } void border_margin() { clrscr(); textcolor(YELLOW); int i,j=3; gotoxy(2,2);cprintf("É"); for(i=0;i<74;i++) { gotoxy(j,2);cprintf("ÿ"); gotoxy(j,2);cprintf("ÿ"); j++; } gotoxy(77,2);cprintf("»"); j=3; for(i=0;i<20;i++) { gotoxy(2,j) ;cprintf("º"); gotoxy(77,j);cprintf("º"); j++; } gotoxy(2,23);cprintf("È");
j=3; for(i=0;i<74;i++) { gotoxy(j,23);cprintf("ÿ"); gotoxy(j,23);cprintf("ÿ"); j++; } gotoxy(77,23);cprintf("¼"); } void printmain() { int k,i; border_margin(); /* user user defined function to draw draw margin */ textbackground(0); textbackground(0); /* sets background none */ textcolor(YELLOW);/* textcolor(YELLOW);/* set text color */ textbackground(RED); gotoxy(6,4);cprintf("É"); k=7; for(i=1;i<=24;i++) { gotoxy(k,4);cprintf("ÿ"); gotoxy(k,4);cprintf("ÿ"); k++; } gotoxy(31,4);cprintf("»"); gotoxy(6,5);cprintf("º gotoxy(6,5);cprintf("º 1. ADD RECORDS
º");
gotoxy(6,6);cprintf("È");gotoxy(31,6);cprintf("¼"); k=7; for(i=1;i<=24;i++) { gotoxy(k,6);cprintf("ÿ"); gotoxy(k,6);cprintf("ÿ"); k++;
}
gotoxy(43,4);cprintf("É"); k=44; for(i=1;i<=24;i++) { gotoxy(k,4);cprintf("ÿ"); gotoxy(k,4);cprintf("ÿ"); k++; } gotoxy(68,4);cprintf("»"); gotoxy(43,5);cprintf("º gotoxy(43,5);cprintf("º 2. DISPLAY RECORDS º"); gotoxy(43,6);cprintf("È");gotoxy(68,6);cprintf("¼"); k=44; for(i=1;i<=24;i++) { gotoxy(k,6);cprintf("ÿ"); gotoxy(k,6);cprintf("ÿ"); k++; } gotoxy(6,9);cprintf("É"); k=7; for(i=1;i<=24;i++) { gotoxy(k,9);cprintf("ÿ"); gotoxy(k,9);cprintf("ÿ"); k++; } gotoxy(31,9);cprintf("»"); gotoxy(6,10);cprintf("º gotoxy(6,10);cprintf("º 3. DELETE RECORDS RECORDS
º");
gotoxy(6,11);cprintf("È");gotoxy(3 gotoxy(6,11);cprintf("È");gotoxy(31,11);cprintf("¼"); 1,11);cprintf("¼"); k=7;
for(i=1;i<=24;i++) { gotoxy(k,11);cprintf("ÿ"); gotoxy(k,11);cprintf("ÿ"); k++; }
gotoxy(43,9);cprintf("É"); k=44; for(i=1;i<=24;i++) { gotoxy(k,9);cprintf("ÿ"); gotoxy(k,9);cprintf("ÿ"); k++; } gotoxy(68,9);cprintf("»"); gotoxy(43,10);cprintf("º gotoxy(43,10);cprintf("º 4. UPDATE RECORDS RECORDS
º");
gotoxy(43,11);cprintf("È");gotoxy gotoxy(43,11);cprintf("È");gotoxy(68,11);cprintf("¼"); (68,11);cprintf("¼"); k=44; for(i=1;i<=24;i++) { gotoxy(k,11);cprintf("ÿ"); gotoxy(k,11);cprintf("ÿ"); k++; } gotoxy(6,14);cprintf("É"); k=7; for(i=1;i<=24;i++) { gotoxy(k,14);cprintf("ÿ"); gotoxy(k,14);cprintf("ÿ"); k++; } gotoxy(31,14);cprintf("»");
gotoxy(6,15);cprintf("º gotoxy(6,15);cprintf("º 5. SEARCH SEARCH FOR RECORDS RECORDS º"); gotoxy(6,16);cprintf("È");gotoxy(3 gotoxy(6,16);cprintf("È");gotoxy(31,16);cprintf("¼"); 1,16);cprintf("¼"); k=7; for(i=1;i<=24;i++) { gotoxy(k,16);cprintf("ÿ"); gotoxy(k,16);cprintf("ÿ"); k++; } gotoxy(43,14);cprintf("É"); k=44; for(i=1;i<=24;i++) { gotoxy(k,14);cprintf("ÿ"); gotoxy(k,14);cprintf("ÿ"); k++; } gotoxy(68,14);cprintf("»"); gotoxy(43,15);cprintf("º gotoxy(43,15);cprintf("º 6. QUIT
º");
gotoxy(43,16);cprintf("È");gotoxy gotoxy(43,16);cprintf("È");gotoxy(68,16);cprintf("¼"); (68,16);cprintf("¼"); k=44; for(i=1;i<=24;i++) { gotoxy(k,16);cprintf("ÿ"); gotoxy(k,16);cprintf("ÿ"); k++; } gotoxy(25,21);cprintf("ENTER gotoxy(25,21);cprintf("ENTER YOUR CHOICE : "); } void printdetail() {
border_margin(); gotoxy(5,7);cprintf("EMPLOYEE gotoxy(5,7);cprintf("EMPLOYEE NO : ");
gotoxy(20,8);cprintf("__________ gotoxy(20,8);cprintf("______________________ _________________________ ______________________"); _________"); gotoxy(5,9);cprintf("NAME gotoxy(5,9);cprintf("NAME
: ");
gotoxy(20,10);cprintf("_________ gotoxy(20,10);cprintf("_____________________ _________________________ _______________________"); __________"); gotoxy(5,11);cprintf("GROSS gotoxy(5,11);cprintf("GROSS PAY : "); gotoxy(20,12);cprintf("_________ gotoxy(20,12);cprintf("_____________________ _________________________ _______________________"); __________"); gotoxy(5,13);cprintf("DESIGNATION : "); gotoxy(20,14);cprintf("_________ gotoxy(20,14);cprintf("_____________________ _________________________ _______________________"); __________"); gotoxy(5,15);cprintf("AGE gotoxy(5,15);cprintf("AGE
: ");
gotoxy(20,16);cprintf("_________ gotoxy(20,16);cprintf("_____________________ _________________________ _______________________"); __________"); gotoxy(5,17);cprintf("SEX gotoxy(5,17);cprintf("SEX
: ");
gotoxy(20,18);cprintf("_________ gotoxy(20,18);cprintf("_____________________ _________________________ _______________________"); __________"); }
References1.en.wikipedia.org/wiki/Doubly_ linked_list linked_list 2. www.iitk.ac.in/esc101/08Jan/lecn www.iitk.ac.in/esc101/08Jan/lecnotes/lecture35.pdf otes/lecture35.pdf 3. thecodecracker.com/c-programming thecodecracker.com/c-programming/double-linked-list /double-linked-list 4. library.maemodocs.nokia.com/.../glib-Doubly-Linked-Lists.html
**********************END******************** **