You are on page 1of 22

TERM PAPER Of FOUNDATION OF COMPUTING Topic: - TELEPHONE DIRECTORY

Submitted To: ms. Sukhdilpreet kaur SHARMA Lecturer lpu 10802359 Submitted By:Name:-ANIL Roll No:-r246b46 Regd No:-

ACKNOWLEDGEMENT
It is not until you undertake the project like this one that you realize how massive the effort it really is, or how much you must rely upon the Selfless efforts and goodwill of others. There are many who helped us with this project, and we want to thank them all from the core of our Hearts. We owe special words of thanks to our Teachers MS.SUKHDILPREET KAUR for their vision, thoughtful counseling and encouragement at every step of the project. We are also thankful to the teachers of the Department for giving us the best of knowledge and guidance throughout the project. And last but not the least, we find no words to acknowledge the financial assistance & moral support rendered by our parents in making the effort a success. All this has become reality because of their blessings and above all by the grace of god.
ANIL SHARMA ROLL NO:-R246B46 REGD.ID:-10802359

TABLE OF CONTENTS
S.N Content o 1 Introduction 2 System Requirement 3 System Description 4 System Design 5 Source code 6 Output 7 Testing 8 Future scope Page no. 4 8 9 10 11 29 32 33

INTRODUCTION:
We have discussed so far various features of C++ language and are ready to write and execute program of modest complexity. However, before attempting to develop complex programs, it is worthwhile to consider some programming techniques that would help design efficient and error free. The program development process includes three important stages, namely, program design, program coding and program testing. All the three stages contribute to the production of high quality program. In TELEPHONE DIRECTORY we have done system design, source coding, and program testing and added many more features to facilitate the user with the best. We have given the user the facility to enter the persons record and providing the option to save and delete that record and many more options. We can improve the efficiency of the system, thus overcome the drawbacks of the existing system. Less human error Strength and strain of manual labour can be reduced High security Data consistency Easy to handle Easy data updating Easy record keeping Backup data can be easily genera

OVERVIEW TO C
4

HISTORY OF C:
C is a popular general purpose programming language. It is one of the most popular computer languages today, because it is a structured, high level, machine independent language. The root of all modern language is ALGOL, introduced in early 1960s. ALGOL was the 1st computer language to use a block structure. Subsequently, several other languages were announced after 1960s. In 1967, Martin Richard developed a language called BCPL i.e. basic combined programming language mainly for writing system software. In 1970, Ken Thompson created a language using many features of BCPL and called it simply B. B was used to create early version of UNIX operating system. C was evolved from ALGOL, BCPL, and B by Dennis Ritchie at the Bell Laboratories in 1972, strongly associated with UNIX. During 1970s, C had evolved into the TRADITIONAL C. With the publication of the book The C Programming language by Brian Kerningham and Dennis Ritchie in 1978, it becomes more powerful. In 1983, American National Standards Institutes (ANSI) appointed a technical committee to define a standard for C. The committee approved a version of C in December 1989, which is now known as ANSI C. It was then approved by International Standard Organization (ISO) in 1990.

IMPORTANCE OF C:
5

The increasing popularity of C++ is probably due to its many desirable qualities. The C++ compiler combines the capabilities of an assembly language with the features of a high level language and therefore it is well suited for writing both system software and business packages. In fact many of the C++ compilers available in the market are written in C++. Programs written in C++ are efficient and fast. This is due to its variety of data types and powerful operators. It is many times faster than BASIC. There are only 32 key words in ANSI C++ and its strength lies in its built in functions. C++ is highly portable; this means that C++ programs written for one computer can be run on another with little or no modifications. C++ language is well suited for structured programming, thus requiring the user to think of a problem in terms of function modules or blocks. This modular structure makes program de-bugging, testing and maintenance easier.Another important feature of C++ is its ability to extend itself. We can continuously add our own functions to C++ library, thus our programming task becomes so easier and simple.

SYSTEM REQUIREMENTS
6

Operating System: RAM: HARD DISK Processor Compiler

Windows 2000/NT/Xp/Vista 256 MB or more 40 GB or more P3 or High Standard C++ Compiler

SYSTEM DESCRIPTION
THE OPERATING SYSTEM USED IN THIS PROJECT IS WINDOWSXPIT HAS MICROSOFT OFFICE INSTALLED IN IT.
7

IT HAS RAM OF 2GB. HARD DISK CAPACITY OF OPERATING SYSTEM IS 250GB. IT CONSISTS OF PENTIUM-4 PROCESSOR.THE OPEREATING SYSTEM ALSO HAS C++ COMPILER. THE SYSTEM ALSO HAS TYPE CONVERSIONS WHICH CONVERT LOWER TO UPPER TYPE. THE OPERATING SYSTEM HAVE 1GB RAM FOR MICROSOFT WORLD.

system design:

START
WELCOME TO THE MAIN MENU

NEW

DISPLAY AN DELETE AN ENTRY ENTRY

IF U WANT ENTER YOUR TO CHOICE DISPLAY EMPTY SAVE CONTINUE


ALL

THE

LOADDELETE ALL ENTRIES FILES

STO END

IF YES IF NO

SOURCE CODE
// TELEPHONE DIRECTORY SYSTEM #include<iostream .h> #include<fstream .h> #include<iomanip .h> #include<string .h> #include<stdlib .h> #include<conio .h> #include<stdio .h> #include<iomanip .h> #include<graphics .h> #include<dos .h> class stud { public:
9

char name[20]; char address[20]; unsigned int ph_no; void get(void); void show(void); void modify(void); }; void stud::get(void) { int i=0; cout< <"\n cin.get(name[i]); while(name[i]!='\n') { i=i+1; cin.get(name[i]); } cin.getline(name,20,'\n'); cout< <" Enter address -> "; Enter name -> ";

cin.getline(address,20,'\n'); fflush(stdin); cout< <" cin>>ph_no; fflush(stdin); } void stud::show(void) { cout< <"\n"; cout<<" cout<<" cout<<" } void main()
10

Enter ph_no\t-> \t";

NAME ADDRESS Ph_No

:"<<"\t"<<name<<"\n"; :"<<"\t"<<address<<"\n"; :"<<"\t"<<ph_no<<"\n";

{ int gdriver = DETECT, gmode, errorcode; int x,y; int midx,midy; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ closegraph(); } y: char*pass="RPV"; char*ppass; gotoxy(25,8); int size=7; settextstyle(7,0,size); setbkcolor(BLUE); setcolor(WHITE); outtextxy(180,50,"WELCOME" ); setcolor(WHITE); outtextxy(250,200,"TO"); settextstyle(8,0,5); setfillstyle(1,DARKGRAY); setcolor(WHITE); outtextxy(60,350,"\n\nTELEPHONE DIRECTORY"); getch();
11

clearviewport(); settextstyle(3,0,4); settextstyle(7,0,4); getch(); clearviewport(); g: ppass=getpass("ENTER THE PASSWORD::"); if(strcmpi(pass,ppass)!=0) { cout<<"\n\t\t\tIncorrect password"; cout<<"\n\t\t\tTry again"; getchar(); goto g; } else {

stud s; char name[20]; char name1[20]; int ch; clrscr(); setbkcolor(BLUE); setcolor(YELLOW); closegraph(); z: cout<<"\n\n\n\n\n\n\n\n\n"; initgraph(&gdriver, &gmode,"c:\\tc\\bgi"); setcolor(BLUE); rectangle(60,10,600,400); setfillstyle(1,YELLOW); bar(61,11,599,399); outtextxy(200,30," HELP -> PRESS ANY KEY 1 TO 6 " );

12

settextstyle(TRIPLEX_FONT ,HORIZ_DIR,4); outtextxy(220,50,"\n\n1. TO ADD " ); setcolor(BLUE); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(220,100,"\n\n2. TO SHOW " ); setcolor(BLUE); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(220,150,"\n\n3. TO SEARCH " ); setcolor(BLUE); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(220,200,"4.\n\n TO MODIFY " ); setcolor(BLUE); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(220,250,"\n\n\n5. TO DELETE " ); setcolor(BLUE); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(220,300,"\n\n\n6. TO EXIT " ); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); outtextxy(220,350," Enter the choice ->"); gotoxy(62,23); cin>>ch; switch(ch) { case 1: //responsible for addition of record { clrscr(); fstream f; f.open("rec",ios::in|ios::out|ios::ate|ios::app|ios::binary); char ans; s.get(); f.write((char *)&s,sizeof(s)); clrscr(); outtextxy(250,360, " Do you want to continue:- "); ans=getche(); if(ans=='Y' || ans=='y'){goto z;} f.close(); break; } case 2: // will show all the contents of the file { clrscr(); cout< <"\n\n";
13

fstream f; f.open("rec",ios::in|ios::out|ios::ate|ios::app|ios::binary); f.seekg(0); int ctr=0; while(f.read((char *)&s,sizeof(s)) ) { ctr=ctr+1; if(ctr==8) {getchar(); clrscr();ctr=0;} s.show(); if(f.eof()==1) {break;} } f.close(); outtextxy(240,350, "

Do you want to continue :-");

char ans; ans=getche(); if(ans=='y'|| ans=='Y'){ closegraph(); goto z;}else{exit(1);} } { case 3: // search gotoxy(60,25); clearviewport(); rectangle(10,10,630,470); setbkcolor(DARKGRAY); textbackground(3); textcolor(5); clrscr(); char ans; ifstream f; stud s; char name[20]; char address[20]; unsigned int ph_no; f.open("rec",ios::in|ios::binary); cout<<"\n\n\n Enter name whose record to be search cin>>name; do { f.read((char *)&s,sizeof(s)); if(f.eof()==1) {break;} if(strcmpi(s.name,name)==0) { cout< <"\n Name :"<<s.name; cout<<"\n address :"<<s.address; cout<<"\n phone_no :"<<s.ph_no; getchar();

:";

} }while(f); f.close(); settextstyle(7,0,1);

14

outtextxy(250,410,"Do You Want To Continue:"); ans=getchar(); if(ans=='Y'||ans=='y') goto z; else { closegraph(); break; } case 4: //for the modification { clrscr(); char ans; fstream f; stud s; char name[20]; char address[20]; unsigned int ph_no; f.open("rec",ios::in|ios::binary); cout<<"\n\n\n Enter person ph_no whose record to be changed :"; cin>>ph_no; do { f.read((char *)&s,sizeof(s)); if(f.eof()==1) {break;} if(s.ph_no==ph_no) { cout< <"\n Current Name :"<<s.name; cout<<"\n Current Address :"<<s.address; cout<<"\n Current Phone No :"<<s.ph_no; getchar(); cout<<"\n Enter the new name :"; cin>>name; cout< <"\n Enter the city :"; cin>>address; cout< <"\n Enter new ph_no :"; cin>>ph_no; strcpy(s.name,name); strcpy(s.address,address); s.ph_no=ph_no; int l=f.tellg(); f.close(); f.open("rec",ios::out|ios::binary|ios::ate); f.seekg(l-sizeof(s)); f.write((char *)&s,sizeof(s)); } }while(f); f.close(); outtextxy(290,360, " Do you want to continue :-"); ans=getche(); if(ans=='Y'||ans=='y') {goto z;} break;

case 5: //responsible for the deletion of the record { clrscr(); char name[20]; stud s;
15

ifstream fin; fstream fout; fin.open("rec",ios::in|ios::binary); fout.open("va",ios::app|ios::binary); cout< <"\n \t\t\t DELETING :-"; int i; fflush(stdin); cout<<"\n\n Enter the name :- "; cin.get(name[i]); while(name[i]!='\n') { i=i+1; cin.get(name[i]); } fflush(stdin); fflush(stdout); cin.getline(name,20,'\n'); while(fin) { fin.read((char *)&s,sizeof (s)); if(strcmp(s.name,name)==0) {fout.read((char *)&s,sizeof(s)); } else { if(fin.eof()==1) {break;} fout.write((char *)&s,sizeof(s)); } } fin.close(); fout.close(); system("del rec"); system("ren va rec"); cout<<"\n Enter is get Deleted:-"; getchar(); char ans; outtextxy(240,340, " Do you want to continue:- "); ans=getche(); if (ans=='y' || ans=='Y') {goto z;} else if (ans=='n' || ans=='N') {getchar(); exit(1); } } case 6: { clearviewport(); outtextxy(250,360,"THE END OF THE PROJECT:-"); outtextxy(260,390,"\n \n\n\n\n PLEASE PRESS ENTER"); getchar(); closegraph(); exit(1); } default: goto z;
16

} } }

OUTPUT

17

18

19

TESTING
THE SOURCECODE DECLARED ABOVE FOR THE PROGRAM OF TELEPHONE DIRECTORY HAS BEEN TESTED AND IT HAS BEEN FOUND THAT THE ABOVE SOURCE CODE IS OKAY AND CORRECT.THE PROGRAM INVOLVES MANY TYPE OF CONVERSIONS. THESE CONVERSIONS HAS TO DONE CAREFULLY. MAINLY THERE ARE TWO TYPES OF TESTING:
20

1-SYSTEM TESTING AND 2-INTEGRATION TESTING SYSTEM TESTING INVOLVES WHOLE TESTING OF PROGRAM AT ONCE AND INTEGRATION TESTING INVOLVES THE BREAKING OF PROGRAM INTO MODULES & THEN TEST.

FUTURE SCOPE
In future one change can be done by adding the fingerprints of the persons of which the address is entered.And one more major change which can be done in this project is that to add the snaps of the person of which the address is entered.We can also add or subtract details of the individual.

21

22

You might also like