You are on page 1of 84

A

PROJECT REPORT
On
TELEPHONE DIRECTORY
(using C++)
Submitted To

KURUKSHETRA UNIVERSITY
In partial fulfillment of requirement for the award Of
Bachelor OF Computer pplication
(Session 2008-2009)
UNDER GUIDANCE O ! SU"#ITTED "Y!
!rs" !##$%S&I SI$'& T$(I SI$')
()ecturer* Computer +epot") (B"C" FI$))
GURU NANK KHALSA COLLEGE
,!-$ $'.

1

I$+#/
CERTIFICATE 3
ACKNOWLEGEMENT 4
PREFACE 5
INTRODUCTION TO C 6
HISTORY OF C 7
WHAT IS OOP? 8
APPLICATION OF C 13
EXISTING SYSTEM 14
PROPOSED SYSTEM 16
MERITS OF SOFTWARE 17
SYSTEM ANALYSIS & DESIGN 18
TESTING 30
CODING 31
OUTPUT 79
FURTURE SCOPE 81
CONCLUSION 82
REFERENCE 83
2
'-.-$$% %&)S CO))'#
,!-$ $'.0123441(&.,$)

Dated...................
TO 5&O! IT !, CO$C#.$
This is to certiIy that !S "T$(I SI$') D/o Sh"
is a student oI B.C.A. III having class Roll No.800 and Univ.
Roll No. ................. oI G.N.K. College, Yamuna Nagar has
worked on the project entitled 6(C+ shop managemaent6.
During the tenure oI the project he was Iound to be Iully
disciplined, hardworking and oI sound character .It is Iurther
certiIied that the project work is candidate's own work and is not
submitted elsewhere Ior any other purpose.
We wish her every success in his liIe.
+r" 7"S SO+&I !r" B&.T B&-S&$
Principal H.O.D.comp.DEPTT
G.N.K .COLLAGE G.N.K .COLLAGE
3
!.S !##$%S&I SI$'&
LECT. G.N.K COLLAGE
C%$O5)#+'#
!#$T
Many people have contributed to being the project into its
present`s Iorm. I am very much thankIul and highly obliged to
Head oI Computer Department !r" B&.T B&-S&$ Ior
their encouragement and insightIul comments at virtually stages
oI both development oI this project and specially providing me
the suitable environment in terms oI hardware & soIt-ware in
our Computer Laboratory.
Further I express my deep gratitude to my guide
!rs" !##$%S&I SI$'&* lecturer, department oI Computer
Application, Ior her valuable suggestions and encouragement.
She was the one who provided me a dynamic, intellectually,
stimulating and constructive setting in which to work and write.

I am also thankIul to my parents & Almighty God whose best
wishes always inspire me to do my duty with Iull determination
4
& hard work. The constant encouragement Irom the parents
added a Ilavor oI victory to this project.
TANVI SINGLA
8.#FC#
In the ever-widening world, the present system oI education
is Iacing new challenges. It is a well-known Iact that today is the
age oI computers, the major achievements oI science and
technology. Now a days everybody is realizing importance oI
computers which is the achievement oI modern IiIth generation
computers.
In the modern era oI science and technology, powerIul
nations have their own super computer. Although, India today
among one progressive nation, still we are lagging behind the
most advance countries in the Iield oI science. .
So realizing this Iact and according to the time command
when computers are necessary and important achievement, I
have chosen Computer Application at my esteemed Institution
'-.- $$% %&)S College"
This degree course aims at providing the student
knowledge about the various applications oI computers. So it is
5
necessary to jump into the practical Iield. Hence, I was assigned
this project which is part oI my syllabus.


Introduction to C++
C is an extension oI C language which is widely used all over.
It is a powerIul modern language that combines the power,
elegance and Ilexibility oI C and the Ieatures oI Object Oriented
Programming (OOP).
It is Iaster and more powerIul than Java, another popular object
oriented language, which lacks certain Ieatures like
pointers and multiple inheritance . With its object oriented
capabilities, such as, data abstraction
Inheritance and polymorphism, C oIIers signiIicant soItware
engineering beneIits over any other programming language.
Programming Pundits expect that C will replace C as a
general purpose programming language in the near Iuture .
C is the language oI the Iuture.
6
&istor9 of C++
C is an object oriented language. It was developed Barnes
Structure at AT&T Bell Laboratories in Murray Hill , New
Jersey , USA , in the early 1980`s.Stroustrup, an admirer oI
Simula67 and a strong supporter oI C , wanted to combine
the best oI both the languages and create a more powerIul
language that could support OOP Ieatures and still retain
the power and elegance oI C . The result was C. ThereIore,
C is an extension oI C with major addition oI the class
construct Ieature oI Simula67. Since the class was a major
addition to the original C language ,Structure initially called
the new language C With Classes` . However, later in 1983, the
name was changed to C. The idea oI C comes Irom the
increment operator , thereby, suggesting that C is an
augmented (incremented) version oI C.
During the early 1990`s, the language underwent a no. oI
improvements and changes. In November 1997, the ANSI / ISO
7
standards committee standardized these changes and added
several new Ieatures to the language speciIications.
5&T IS OO8:
The major motivating Iactor in the invention oI object
oriented approach is to remove some oI the Ilaws
encountered in the procedural approach . OOP treats data as
a critical element in the program development and does not
allow it to Ilow Ireely around the system. It ties data more
closely to the Iunctions that operate on it, and protects it Irom
accidental modiIications Irom outside Iunctions. It allows
decomposition oI problems into a number oI entities called
Objects and then builds data and Iunctions around these objects.
The organization oI data and Iunctions in OOP is shown below:
Stri;ing features of OO8

Emphasis on data rather than procedure.
Programs are divided into objects.
8
Data structures are designed such as they characterize the
objects.
Functions that operate on the data oI an object are tied
together in the data structure.
Data is hidden and can not be accessed by external Iunctions.
Objects may communicate with each other through Iunctions.
New data and Iunctions can be easily added wherever
necessary.
Follows bottom - up approach in program design.
Basic concepts in OOP
1. Ob<ects they are the basic run time entities in object
oriented system . They may represent a person, a place, a bank
account, a table oI data or any item that the program has to
handle . They may represent user-deIined data such as vectors,
time and list When a program is executed, the objects interact
by communicating with each other. Each object contains data
and code Ior manipulation

9
2. Classes - The entire set oI data and code oI an object can be
made user deIined type with the help oI a class. Once a class
have been deIined, we can create any no. oI objects belonging
to that class . Each object is associated with the data oI type
class with which they are created. A class is thus a collection oI
objects oI similar type. For e.g., mango, apple, banana etc. all
are the members oI class Iruit. Classes are built - in data types
and behave like built - in types oI a programming language.
3. +ata bstraction = #ncapsulation - The wrapping up oI
data & Iunctions into a single unit (called class) is known as
Encapsulation . It ia the most striking Ieature oI a class. The data
is not accessible to the outside world, and only those Iunctions
which are wrapped in the class can access it. These Iunctions
provide the interIace between the object`s data and the program.
This insulation oI data oI data Irom direct access by the program
is called Data - Hiding or InIormation - hiding.
Abstraction reIers to the act oI representing essential Ieatures
without including the background details. Classes use the
concept oI abstraction and are deIined as list oI abstract
attributes, such as, size, weight, cost and Iunctions . Functions
10
that operate on these data are called methods` or member
Iunctions.
4. Inheritance - It is the process by which objects oI one class
can acquire the properties oI another class. It supports the
concept oI hierarchical classiIication. For e.g., scooter` is a part
oI 2- wheelers` which is again a part oI class vehicles` . The
principle behind this sort oI division is that each derived class
shares common characteristics with the class Irom which it is
derived.
5. Polymorphism -It means the ability to take more than one
Iorms .An operation may exhibit diIIerent behaviors in diIIerent
instances that which depends upon the type oI data used in the
operation. For e.g., Consider ` operator. For two nos. it will
generate the sum, but Ior two strings, it will concatenate them.
When a single Iunction name is used to handle diIIerent no. and
diIIerent type oI arguments, it is called Function Overloading.
6. Dynamic Binding - It reIers to the linking oI the procedure
call to the code to be executed in response to the call. It means
11
that the code associated with a given procedure call is known
until the time oI the call at the run - time. It is associated with
polymorphism and inheritance.

7. Message Passing - An OO program consists oI a set oI objects
that communicate with each other. The process oI programming
in an OO language, thereIore, involves:
a) Creating classes that deIine objects and their behavior.
b) Creating objects Irom class deIinitions.
c) Establishing communication among objects.
The concept oI message passing makes it easier to talk about
building systems that directly model or simulate their real -
world counterparts.
12
88)ICTIO$S OF C++
C is a versatile language Ior handling very large programs. It
is suitable Ior virtually any programming task including editors,
compilers, data base systems, communication systems and any
complex real liIe application systems.
C allows us to create hierarchy related objects. So, we can
build special object oriented libraries which can be used later
by many programmers.
While C is able to map the real world problems the C part
oI C gives the language the ability to get close to the
machine language details
C programs are easily maintainable and expandable.
It is expected that C will replace C as a general purpose
language in the near Iuture.
13
#/ISTI$' S,ST#!
In general, the telephone board members concerning
with keeping the record oI customer Iace problems specially in
case oI editing the customer record, those people can get the
problem because they have to mention the data entered beIore
changes and aIter changes. Moreover they may have diIIerent
no. oI Iiles Ior storing the data which may cause the redundancy
oI data or inconsistency oI data.
This may take much time oI the staII members and aIter
working so many hours the members can Ieel tired also. It
means the existing system is time consuming
Problems involving in existing system
Following are the problems in the existing system:
Time consuming>
II the area is big Ior where the telephone customer data is
prepared then Iiles Ior keeping the records may take a lot oI
time.
14
Clerical mista;es>
Data being operated manually sometimes leads to errors
because oI the skills oI the telephone board`s members writing
the each and every record or Ior some other reason.
Secrec9>
The Iiles Ior keeping record that are maintained aIter a regular
time period are prepared with the co-operation oI many
members oI board oI diIIerent areas. So, anybody can take secret
inIormation out oI these registers and that is why they lack
secrecy.
+ata collection mista;es>
DiIIerent members may have diIIerent inIormation. The
inIormation is to be registered can be registered wrong or no. oI
times.
Storage>
The records are stored in the Iiles. Those Iiles can be lost or
teared.
15
8.O8OS#+ S,ST#!
This project is developed in C LANGUAGE. This project is
used Ior storing the telephone no. oI the customers. When
you start the project, you will see the main menu on the
screen:
a.) Add Entry
b.) Delete Entry
c.) Search Entry
d.) Edit Entry
e.) Display Entry
I.) Exit
In this project We can get the detail oI customer newly added,
then can made any type oI query, can made modiIications and
deletion oI customer record is prepared.
Computers can play a vital role in the day to day working in
telephone department. The use oI computers in telephone
department can be visualized in two aspects. Firstly computers
can be used as general-purpose machines Ior management oI
department Ior storing records. Secondly, computers can
16
be used Ior a special purpose Ior diIIerent application.
!#.ITS OF SOFT5.#
II we handle the system manually, a large number oI
manpower`s are required. With computerization
system manpower may be saved. Time may also be
saved.
Reducing the time Iactor Ior payment iI money,
computer will do the job accurately, eIIiciently and in
time up to date inIormation may be obtained Irom
computer any time.
The output generated by the computer will be in
tabulated Irom which will be understood more clearly.
Neatly typed results will be taken hence making the
reading easy. Multiple copies can be generated at a
time, thus saving the time.
In order to success any record it will only require to
give a suitable command to the computer and the
desired record will either be displayed on the screen or
printer.
17
S,ST#! $),SIS = +#SI'$
a.) It is necessary to check that the project is technically
Ieasible, thus the origination eIIect has the technology and skill
necessary to carry out the project and iI not, how the required
technology and skill should is obtained.
b.) Operational Ieasibility must be established. To do this,
it is necessary to concern the system user to see iI the proposed
solution is satisIying the user objective.
c.) Project economic Ieasibility needed to be checked. The
study must determine whether the project goal can be achieved
within a resource unit allocated to it. It also determines whether
it is worthwhile to project or whether beneIits Irom new system
will be terminated.
nal9sis
Analysis speciIies that what the system is?
Analysis is a detailed study oI various operations perIormed by
the system and their relationship with on outside pI the system.
18
A key question is what must be done to solve the problem? One
aspect oI analysis is deIining the boundaries oI the system. The
interviews in the common tool used in analysis. It requires
special skills and sensitivity to the subjects being interviewed.
Training, experience and common sense are required Ior the
inIormation needed to do analysis.
System analysis is the dissection oI a system in to its component
piece to study how those component pieces interact and works.
System analysis is perIormed to do system synthesis is re
assembly oI a system`s component piece back into a whole
system. In other word system analysis is a term that collectively
describes the early phase oI system development.
In this project I interpret Iirst oI manual system in which I
get that I have to store name, surname, home phone no., oIIice
no, mobile no. ,oI a person. But I Iind out some problems in
manual system such as time consuming, privacy, & cost. So I
developed a project to store the database oI a person in which
problems involved in manual system is removed. system

19
8roblem +efinition>

SoItware is likely puzzle to solve. BeIore we can
design, we need to decide just what it is we are trying to solve
problem deIinition Ior a soItware project usually starts out a
vague description oI the actual problem. It deIines the problem
to be solved and then sets the direction Ior the whole project. It
also deIines the project bound. The resources to be made
available to the project are also speciIied in this phase.
20
Feasibilit9 Stud9

When the analysis phase is over we switch over to
Ieasibility study. First we prepare a Ieasibility document to
evaluate the solutions. Secondly we remove only conIusions in
the system development such as the constraints. The Ieasibility
study is decision documents which answer three key questions.
1. Is there a new and better way to do the job that will beneIit
to the user?
2. What are the costs and savings oI the alternatives?
3. What is recommended?

Feasibility considerations

#conomic feasibilit9
#conomic anal9sis is also called cost beneIit analysis. It
is used to determine the beneIits and savings that are expected
21
Irom candidate system and we make the comparison oI the cost
against beneIits. II beneIits exceed the costs, the system is
designed otherwise alterations have to be made. Telephone
Project will reduce the use oI paper.By using this project the cost
is reduced. So the proposed system is economical Ieasible.
Technical feasibilit9
Technical Ieasibility is the examination oI existing
system to support the proposed system. II the existing system
can support the new system with in the technical aspects
available then the proposed system can be developed. Otherwise
we have to take in consideration the budget and other technical
aspects oI new system. This project is technical Ieasible because
in the case oI manual system a lot oI man is required but in case
oI computerized system it reduce the man power. In this
Existing system can totally support the proposed system.
Beha?ioral feasibilit9
This Ieasibility can be identiIied by operational
Ieasibility. People are inherently resistant to change. We must
estimate the reaction oI the staII according to the new system.
22
Whenever we switched over Irom manual to computerized
system we should trained the users, provide the required
Iacilities, and educate them to avoid Irustration oI the staII
regarding new system. It will reduce the eIIorts made by human
means less eIIorts by human are required so people working in
organization will preIer it as the best. This project is behavioral
Ieasible the staII member oI the organization will have to work
less and with less eIIort so they preIer it most .

23
+#SI'$
The most creative and challenging step oI the designing oI the
project. The term design describes a Iinal project and process by
which it is developed. It includes the construction oI the
program and program testing.
I$8-T +#SI'$
Input design is a part over all system, which requires very
careIul alteration. OIten the collection oI input data is most
expensive part oI the system, in terms oI both the equipments
used and the number oI people involved, it is prone to error. II
data going into the system designer has a number oI clear
objectives in input design.
To produce a cost eIIective method oI input.
To achieve the highest possible level oI accuracy.
24
To ensure that the input is acceptable to and understand by
the user staII.
Several activities have to be carried out as the part oI over
all input process.
They include some or all oI the Iollowing:
Data recording i.e. collection oI data at its source. As data
about the customer name, address, phone no etc are
collected in this project.
Data conversion i.e. conversion oI input data to a computer
acceptable medium. As all details here are converted in
computer acceptable Iorm.
Data transcription i.e. transIer iI data into the computer
Iorm.
Data veriIication i.e. checking the conversion. Here we
check whether the inIormation converted in computer
acceptable Iorm is correct or not.
Data control i.e. transmitting or transporting the data to the
computer.
25
Moreover checking the accuracy and controlling the Ilow
oI data to the computer.
Data validation i.e. checking the input data by the program
when it enters the computer system.
Data correction i.e. correcting the errors that are Iound at
any oI the earlier stage.
O-T8-T +#SI'$
Output Irom computer system is requiring communicating the
result oI processing to users. They are used to provide a
permanent copy oI this result Ior later consultation. They are
also various type oI outputs require by most system.
#@ternal output>
II the destination is outside the organization and which
requires a special attention because they project the image oI
organization.
Internal output>
26
II the destination is with in the organization and which
requires a careIul design because they are the users main
interIace with the computer.
Operational output>
These are used with in computer department e.g. program
Interacti?e output>
Which involve user in communication directly with
computer?
Turn round output>
That is reentrant documents to which data will be added
beIore they are return to the computer Ior Iurther processing.
The output generated is as Iollows:
Add Entry
Delete Entry
Edit Entry
Search Entry
Display Entry
27
FI)# +#SI'$
File design consideration choice oI medium:
Choice oI correct device Ior storing a Iile is most important
with master Iiles. They are some oI the consideration:
8urpose of file
Direct access device such as disk can be used as a mean oI
holding transaction data or immediate Iiles. Serial reading and
processing Irom disk may be quicker than reading Irom
magnetic tape. It is possible to load transaction to speciIic area
oI the disk.
28
&ardware
Where there is no possibility oI additional hardware Ior a
proposed system the choice oI media is restricted particularly
small installations. It may not be possible to put the Iile on the
best Iile on best possible medium, the system analyst will have
less diIIiculty deciding which medium to use, but more
diIIiculty in the procedures which meet the need oI the users.
!ethod of access
1. Sequential access mode
2. Random access mode
In the sequential access mode records are accessed one by one.
Magnetic tape is best suited Ior sequential accessing. In random
access mode, any record Irom any location can be accessed via
accessing Iunction e.g. Ior array accessing Iunction is given by
A (K)
Disks are best suited Ior random access.
29
T#STI$'
During system testing, the system is used experimentally to
ensure that the soItware does not Iail, i.e. it will run according to
its speciIications and in the way user expect.
Special test data are input Ior processing, and the results
examined,. A limited number oI users may be allowed to use the
system so analysts can see whether they use it in unIoreseen
ways. It is preIerable to discover any surprises beIore the
organization implements the system and depends on it.
Testing is done throughout systems development at various
stages not just at end . it is always a good practice to test the
system at many diIIerent levels at various intervals, that is, sub-
30
system, program modules as work progresses and Iinally the
system as a whole. II this is not done, then the poorly tested
system can Iail aIter installation.
I test this project in two parts.
1" -nit testing"
A" Integration testing"
-nit testing
By unit testing means that pick a module and test it aIter it
pick a second module and test it this process will take continue
till the end oI module. In this project I have six module named
as add entry, edit entry, search entry, delete entry, display entries,
exit.
In the project Iirst oII all I picked Iirst module i.e. add entry test
it and check with a dummy data and it gives correct output then
I picked a second module i.e. edit entry which modiIy the entry
and check it .again I picked a module i.e. search entry so on until
the last module i.e. exit is tested.
31
Integration testing
When unit tests are satisIactorily concluded, the system as a
complete entity must be tested. At this stage, end users and
operators become actively involved in testing. While testing one
should also test to Iind discrepancies between the system and its
original objective, current speciIications and systems
documentation.
In this project when I have completed unit testing then I
pick all the module combine them with the help oI switch
statement and put them in the main program and test the project
with the help oI dummy data then the project gives result to me
and I compared it with the expected output. Then the output is
matched. so that I can say that on the behalI oI testing my
project give the right output and is able to store the inIormation
oI an person.
32
//TELEPHONE DIRECTORY
#includeIstream.h~
#includeiostream.h~
#includeconio.h~
#includestdio.h~
#includestring.h~
#includeIcntl.h~
#includedos.h~
#includeiomanip.h~
#includegraphics.h~
#include stdlib.h~ Ior Exit()
#deIine pa1 "bgi"
//#deIine pa2 "teletry.dat" // declare Iile as macro
// deIine class
int FLAG1;
class person
33

public:
unsigned long recordid;
char personname|20|;
char resaddress|30|;
char respincode|15|;
char resphone1|15|;
char occu|15|;
char companyname|20|;
char oIIaddress|20|;
char oIIpincode|15|;
char oIIphone1|15|;
// Generating autopmatic record number Ior customer
unsigned long getrecno();
// Function to input data records Ior customers
void getdata();
/* Function to modiIy the existing data oI any customer
according to customers record no. */
void moddata(unsigned long r);
// Display individual customers telephone and address
inIormation
34
void showdata();
// Appends new customer inIormation into data Iile
void addobject();
// Deletes individual customer inIormation
void delobject();
// ModiIy the customer inIormation in database
void modiIyobject();
// Function is used to search any particular customer record
void searchobject();
// Generates global report oI telephone number holders
void reports();
// Creates a square box
void box(int x1,int y1,int x2,int y2);
void end();
void screen();
};
person pers; // Declares global person Object
// Function body Ior box
void person::box(int x1,int y1,int x2,int y2)

Ior(int colx1;colx2;col)
35

gotoxy(col,y1);
cprintI("c",196);
gotoxy(col,y2);
cprintI("c",196);
}
Ior(int rowy1;rowy2;row)

gotoxy(x1,row);
cprintI("c",179);
gotoxy(x2,row);
cprintI("c",179);
}
gotoxy(x1,y1);
cprintI("c",218);
gotoxy(x1,y2);
cprintI("c",192);
gotoxy(x2,y1);
cprintI("c",191);
gotoxy(x2,y2);
cprintI("c",217);
36
}
// Declaration Ior the getrecno()
unsigned long person::getrecno()

unsigned long recno0;
Istream Iile;
Iile.open("teletry.dat",ios::in);
Iile.read((char *)&pers,sizeoI(pers));
Iile.seekg(0,ios::end);
// tellg() returns the current stream position
int i,n0;
nIile.tellg();
iI(n0)

recno1;
return 1;
}
// isizeoI(pers);
//Iile.seekg(-i,ios::end);
Iile.seekg(0,ios::beg);
while(!Iile.eoI())
37

iI(Iile.eoI())
break;
Iile.read((char *)&pers,sizeoI(pers));
recno pers.recordid;
}
recno;
Iile.close();
Iile.Ilush();
IIlush(stdin);
IIlush(stdout);
return recno;
}
// The Iunction Ior addition oI record
void person::addobject()

Istream Iile;
char ch'y';
while(ch'y' ,, ch'Y')

Iile.open("teletry.dat",ios::app , ios::in , ios::out);


38
// call Iunction to input the Iield value oI telephone
directory
IIlush(stdin);
IIlush(stdout);
getdata();
iI(FLAG-1)

Iile.close();
IIlush(stdin);
IIlush(stdout);
return;
}
Iile.seekg(0,ios::end);
Iile.write((char *)&pers,sizeoI(pers));
Iile.Ilush();
Iile.close();
gotoxy(22,20);
cout "Want to add more records (y/n).....";
IIlush(stdin);
IIlush(stdout);
chgetch();
39
}
}
// Function deIinition oI getdata()
void person :: getdata()

int Ilag1;
clrscr();
gotoxy(70,1);
cout "Exit 0~";
gotoxy(20,3);
cout " ADDITION ";
gotoxy(22,4);
cout "";
// calling Iunction to get record no automatically
IIlush(stdin);
IIlush(stdout);
person::recordid person::getrecno();
gotoxy(6,6);
cout "RECORDID :"recordid;
pers.box(2,22,65,24);
gotoxy(5,23);
40
cout "Enter Subscriber Name";
do

gotoxy(6,7);
cout "\aEnter Name :";
IIlush(stdin);
IIlush(stdout);
gets(personname);
iI((strlen(personname)0) ,, (strlen(personname)~15))

Ilag1;
gotoxy(5,23);
cout "\aName may not blank or length greater than 15";
getch();
gotoxy(5,23);
cout "\a ";
gotoxy(5,23);
cout "Enter Name :";
}
else
Ilag0;
41
iI((strcmp(personname,"0")0))

FLAG-1;
return;
}
}while(Ilag);
Ilag1;
gotoxy(5,23);
cout "Enter Address oI Subscriber";
do

gotoxy(6,8);
cout "Residential address :";
IIlush(stdin);
IIlush(stdout);
gets(resaddress);
iI((strlen(resaddress)0) ,, (strlen(resaddress)~30))

Ilag1;
gotoxy(5,23);
42
cout "\aAddress may not blank or length greater than
15";
getch();
gotoxy(5,23);
cout "\a ";
gotoxy(5,23);
cout "\aEnter Address oI Subscriber";
}
else
Ilag0;
iI((strcmp(resaddress,"0")0))

FLAG-1;
return;
}
}while(Ilag);
Ilag1;
gotoxy(5,23);
cout "Enter Residential Phone";
do
43

gotoxy(6,9);
cout "Residential Phone :";
IIlush(stdin);
IIlush(stdout);
gets(resphone1);
iI((strlen(resphone1)0) ,, (strlen(resphone1)~30))

Ilag1;
gotoxy(5,23);
cout "\aPhone may not blank or length greater than 15";
getch();
gotoxy(5,23);
cout "\a ";
gotoxy(5,23);
cout "\aEnter Residential Phone";
}
else
Ilag0;
iI((strcmp(resphone1,"0")0))

44
FLAG-1;
return;
}
}while(Ilag);
Ilag1;
//
gotoxy(5,23);
cout "Enter Occupation oI Subscriber";
do

gotoxy(6,10);
cout "Enter occupation :";
IIlush(stdin);
IIlush(stdout);
gets(occu);
iI((strlen(occu)0) ,, (strlen(occu)~30))

Ilag1;
gotoxy(5,23);
cout "\aOccupation may not blank or length greater than
15";
45
getch();
gotoxy(5,23);
cout "\a ";
gotoxy(5,23);
cout "\aEnter Occupation oI Subscriber";
}
else
Ilag0;
iI((strcmp(occu,"0")0))

FLAG-1;
return;
}
}while(Ilag);
Ilag1;
//
gotoxy(5,23);
cout "Enter Company Or Dept. Phone";
do

gotoxy(6,13);
46
cout "Enter OIIice Phone :";
IIlush(stdin);
IIlush(stdout);
gets(oIIphone1);
iI((strlen(oIIphone1)0) ,, (strlen(oIIphone1)~15))

Ilag1;
gotoxy(5,23);
cout "\aDept. Phone may not blank or length greater than
15";
getch();
gotoxy(5,23);
cout "\a ";
gotoxy(5,23);
cout "\aEnter Company or Dept. Phone";
}
else
Ilag0;
iI((strcmp(oIIphone1,"0")0))

FLAG-1;
47
return;
}
}while(Ilag);
Ilag1;
} // end oI Iun getdata()*/
// Function DeIinition Ior the moddata()
void person::moddata(unsigned long r)

clrscr();
gotoxy(20,3);
cout " UPDATION ";
gotoxy(22,4);
cout "";
pers.recordidr;
gotoxy(6,6);
cout "RECORDID :"pers.recordid;
gotoxy(6,7);
cout "Enter Name :";
gets(pers.personname);
48
gotoxy(6,8);
cout "Residential address :";
gets(pers.resaddress);
gotoxy(6,9);
cout "Residential Phone :";
cin ~~pers.resphone1;
gotoxy(6,10);
cout "Enter occupation :";
gotoxy(6,13);
cout "Enter OIIice Phone :";
cin ~~pers.oIIphone1;
}
/* Function deIinition oI showdata() oI telephone
records aIter search Iunction */
void person::showdata()

clrscr();
int dd,mm,yy;
struct date d;
getdate(&d);
ddd.daday;
49
mmd.damon;
yyd.dayear;
gotoxy(28,3);
textcolor(REDBLINK);
cputs("D I S P L A Y");
textcolor(YELLOW);
textbackground(GREEN);
pers.box(2,5,76,16);
gotoxy(22,4);
textcolor(WHITE);
textbackground(BLACK);
cputs("");
textcolor(MAGENTA);
gotoxy(4,7);
cputs("RECORDID :");
cout" "pers.recordid;
gotoxy(60,7);
cputs("Date:");
coutdd"-"mm"-"yy;
gotoxy(4,8);
cputs("Name :");
50
gotoxy(23,8);
puts(pers.personname);
gotoxy(4,9);
cputs("Resi Address :");
gotoxy(23,9);
puts(pers.resaddress);
gotoxy(4,10);
cputs("Resi Phone1 :");
gotoxy(23,10);
puts(pers.resphone1);
gotoxy(40,10);
cputs("Occupation :");
gotoxy(57,10);
puts(pers.occu);
gotoxy(4,11);
cputs("Company Name :");
gotoxy(23,11);
puts(pers.companyname);
gotoxy(4,12);
cputs("Company Address :");
gotoxy(23,12);
51
puts(pers.oIIaddress);
gotoxy(4,13);
cputs("OIIice Phone1 :");
textcolor(WHITE);
textbackground(BLACK);
gotoxy(15,21);
cputs("Press Any Key To Continue...");
IIlush(stdin);
IIlush(stdout);
}
// This is a Iunction Ior the deletion oI a record
void person::delobject()

unsigned long recno;
unsigned long n0;
Istream Iile,Iile2;
clrscr();
Iile.open("teletry.dat",ios::in , ios::out , ios::app);
Iile2.open("temptel.dat",ios::in , ios::out , ios::app);
gotoxy(30,4);
cout "R E M O V E R E C O R D";
52
gotoxy(23,5);
cout "";
gotoxy(10,10);
cout "Enter The Recordid to be Deleted...";
IIlush(stdin);
IIlush(stdout);
cin ~~recno;
int i,j;
Iile.seekg(0,ios::end);
nIile.tellg();
iI(n0)

clrscr();
gotoxy(20,13);
cout "File is empty";
Iile.close();
Iile2.close();
getch();
return;
}
int ctr0;
53
Iile.seekg(0,ios::beg);
while(!Iile.eoI())

Iile.read((char *)&pers,sizeoI(pers));
iI(recnopers.recordid)
ctr;
}
iI(ctr0)

clrscr();
gotoxy(25,13);
sound(3000);
sound(1000);
sound(2000);
cout "Record Number Not Found().";
delay(20);
nosound();
Iile.close();
Iile2.close();
getch();
return;
54
}
Iile.seekg(0,ios::beg);
while(Iile.read((char *)&pers,sizeoI(pers)))

iI(recno!pers.recordid)
Iile2.write((char *)&pers,sizeoI(pers));
}
Iile.close();
Iile2.close();
rename("temptel.dat","teletry.dat");
remove("temptel.dat");
clrscr();
gotoxy(25,13);
cout "Record Has Been Deleted SuccessIully";
getch();
}
// Iunction Ior modiIy record
void person::modiIyobject()

Istream Iile;
unsigned long rec;
55
char ans;
clrscr();
gotoxy(20,15);
cout "Enter The Record ID to ModiIy.....";
gotoxy(53,15);
IIlush(stdin);
IIlush(stdout);
cin ~~rec;
Iile.open("teletry.dat",ios::out , ios::in);
Iile.seekg(0,ios::end);
long n0;
nIile.tellg();
iI(n0)

clrscr();
gotoxy(25,13);
cout "Iile empty";
getch();
return;
}
Iile.seekg(0,ios::beg);
56
while(!Iile.eoI())

Iile.read((char *)&pers,sizeoI(pers));
iI(pers.recordidrec)

showdata();
gotoxy(20,23);
cout "Want to Update this Record.....";
IIlush(stdin);
IIlush(stdout);
gotoxy(53,23);
ansgetch();
iI(ans'y' ,, ans'Y')

cout "ModiIied value"endl;


showdata();
getch();
Iile.seekg(n-sizeoI(pers),ios::beg);
moddata(rec);
Iile.write((char *)&pers,sizeoI(pers));
Iile.Ilush();
57
break;
}
else

Iile.close();
Iile.Ilush();
return;
}
}
nIile.tellg();
}
Iile.close();
Iile.Ilush();
} // end oI Iunction modiIyobject()
// Function declaration Ior the search phone inIormation
/* By using this Iunction the phone.data data Iile is searched
according
to RECORD ID,NO ,NAME PHONE NO,FAX NO,E-MAIL
NO.respactively and
displays all the records on screen */
void person::searchobject()
58

Istream Iile;
unsigned long rec;
char phno|15|;
char Iaxno|15|;
char mail|30|;
char name|20|;
char ch;
do

clrscr();
int count0;
pers.box(10,5,67,20);
gotoxy(21,7);
cout "\tSEARCH MENU";
gotoxy(20,8);
cout "";
gotoxy(20,10);
cout "1. RECORD ID NO.";
gotoxy(20,11);
cout "2. NAME ";
59
gotoxy(20,12);
cout "3. PHONE NO.";
gotoxy(20,13);
cout "4. Exit";
gotoxy(20,16);
cout "Enter The Field To Search.....";
IIlush(stdin);
IIlush(stdout);
gotoxy(20,60);
chgetch();
switch(ch)

case '1':
clrscr();
gotoxy(20,15);
cout "Enter The Record ID to Search.....";
gotoxy(20,16);
cin ~~rec;
Iile.open("teletry.dat",ios::in);
Iile.seekg(0,ios::beg);
Iile.read((char *)&pers,sizeoI(pers));
60
while(!Iile.eoI())

iI(pers.recordid0)
break;
iI(pers.recordidrec)

count;
pers.showdata();
getch();
}
Iile.read((char *)&pers,sizeoI(pers));
}
Iile.close();
gotoxy(24,23);
cout "Records Found "count;
getch();
break;
case '2' :
clrscr();
gotoxy(20,15);
cout "Enter The Person Name to Search.....";
61
gotoxy(20,16);
gets(name);
Iile.open("teletry.dat",ios::in);
Iile.seekg(0,ios::beg);
Iile.read((char *)&pers,sizeoI(pers));
while(!Iile.eoI())

iI((strcmpi(name,pers.personname))0)

count;
pers.showdata();
getch();
}
Iile.read((char *)&pers,sizeoI(pers));
}
Iile.close();
gotoxy(24,23);
cout "Records Found "count;
getch();
break;
case '3':
62
clrscr();
gotoxy(20,15);
cout "Enter The Phone NO. to Search.....";
gotoxy(20,16);
gets(phno);
Iile.open("teletry.dat",ios::in);
Iile.seekg(0,ios::beg);
Iile.read((char *)&pers,sizeoI(pers));
while(!Iile.eoI())

iI((strcmpi(pers.oIIphone1,phno)0)
//,, (strcmp(pers.oIIphone2,phno)0)
,, (strcmp(pers.resphone1,phno)0))

count;
pers.showdata();
getch();
}
Iile.read((char *)&pers,sizeoI(pers));
}
Iile.close();
63
gotoxy(24,23);
cout "Records Found "count;
getch();
break;
case '4':
clrscr();
break;
deIault :
clrscr();
cout "\n\a";
gotoxy(25,13);
textcolor(RED);
cputs("Wrong Entery");
textcolor(WHITE);
textbackground(BLACK);
getch();
IIlush(stdin);
IIlush(stdout);
}// end oI switch
}while(ch!'4');
} // end Io search Iunction
64
/* This Iunction is generated diIIerent reports */
void person::reports()

Istream inIile;
char ch;
int row0;
do

clrscr();
gotoxy(25,7);
cout"R E P O R T M E N U";
gotoxy(25,8);
cout " ";
gotoxy(15,12);
cout"1. LIST OF NAMES, RESIDENCE & OFFICE
PHONE NO.";
gotoxy(15,13);
cout"2. LIST OF NAMES, OFFICE, ADDRESS &
PHONE NO.";
gotoxy(15,14);
65
cout"3. LIST OF NAMES, RECORDS NO &
ADDRESS.";
gotoxy(15,15);
cout"4. EXIT";
gotoxy(22,18);
cout "Enter Your Choice.....";
IIlush(stdin);
IIlush(stdout);
gotoxy(20,60);
chgetch();
IIlush(stdin);
IIlush(stdout);
switch(ch)

case '1':
clrscr();
row0;
cout "\n NAME RESIDENCE PHONE
OFFICE PHONE";
cout
"\n---------------------------------------------------";
66
inIile.open("teletry.dat",ios::in);
inIile.seekg(0,ios::beg);
// read Iile Irom beginning
inIile.read((char *)&pers,sizeoI(pers));
iI(pers.recordid0) // iI Iile empty
break;
cout endl;
while(!inIile.eoI())

cout setiosIlags(ios::leIt)
setw(28)pers.personname
setw(30)pers.resphone1
setw(30)pers.oIIphone1
endl;
inIile.read((char *)&pers,sizeoI(pers));
iI(row50 && row!0)

getch();
clrscr();
cout "\n NAME RESIDENCE
PHONE OFFICE PHONE NO";
67
cout
"\n###############################################
##################\n";
IIlush(stdin);
IIlush(stdout);
}
row;
}
inIile.close();
gotoxy(20,24);
cout "Press any key to continue.....";
getch();
break;
case '2':
clrscr();
row0;
cout "\n NAME COMPANY NAME
OFFICE PHONE1";
cout
"\n-----------------------------------------------------------------\n";
inIile.open("teletry.dat",ios::in);
68
inIile.seekg(0,ios::beg);
// reads Iile Irom beginning
inIile.read((char *)&pers,sizeoI(pers));
iI(pers.recordid0) // iI Iile empty
break;
while(!inIile.eoI())

cout endl;
cout setiosIlags(ios::leIt)
setw(28)pers.personname
setw(30)pers.companyname
setw(30)pers.oIIphone1;
inIile.read((char *)&pers,sizeoI(pers));
iI(row50 && row!0)

getch();
clrscr();
cout "\n NAME COMPANY
NAME OFFICE PHONE1";
69
cout
"\n***********************************************
******************\n";
IIlush(stdin);
IIlush(stdout);
}
row;
}
inIile.close();
gotoxy(20,24);
cout "Press any key to continue.....";
getch();
break;
case '3':
clrscr();
row0;
cout "\n RECORDS NO. PERSON
NAME RES.ADDRESS";
cout
"\n------------------------------------------------------------------";
inIile.open("teletry.dat",ios::in);
70
inIile.seekg(0,ios::beg);
// read Iile Irom beginning
inIile.read((char *)&pers,sizeoI(pers));
iI(pers.recordid0) // iI Iile empty
break;
while(!inIile.eoI())

cout endl;
cout setiosIlags(ios::leIt)
setw(28)pers.recordid
setw(30)pers.personname
setw(30)pers.resaddress;
inIile.read((char *)&pers,sizeoI(pers));
iI(row50 && row!0)

getch();
clrscr();
cout "\n RECORDS NO.
PERSON NAME RES.ADDRESS ";
71
cout
"\n
";
IIlush(stdin);
IIlush(stdout);
}
row;
}
inIile.close();
gotoxy(20,24);
cout "Press any key to continue.....";
getch();
break;
case '4':
clrscr();
break;
deIault :
clrscr();
textcolor(YELLOW);
gotoxy(25,13);
cputs("Wrong Entry");
72
textcolor(WHITE);
textbackground(BLACK);
getch();
IIlush(stdin);
IIlush(stdout);
break;
}
}while(ch!'4');
}
// screen Iunction to display graphics
void person::screen()

int driver,mode,i;
char ch;
clrscr();
// pers.box(25,1,55,7);
gotoxy(33,2);
cout "W E L C O M E";
gotoxy(37,4);
cout "T O";
gotoxy(33,6);
73
cout "P R O J E C T";
// pers.box(18,12,58,14);
gotoxy(20,13);
cout "Do You Direct Run Project (y/n)..?";
chgetch();
iI(ch'y')

IIlush(stdin);
IIlush(stdout);
return;
}
exit(0);
// getch();
closegraph();
}
//
void pw()

int Ilag1;
int ctr0;
char ch;
74
int FLAG0;
clrscr();
gotoxy(25,13);
cout "Ready";
delay(500);
gotoxy(31,13);
cout ".";
delay(500);
gotoxy(32,13);
cout ".";
delay(500);
gotoxy(33,13);
cout ".";
delay(500);
gotoxy(34,13);
cout ".";
delay(500);
gotoxy(35,13);
cout ".";
}
// Main program starts here
75
void main()

char ch;
pers.screen();
getch();
do

clrscr();
gotoxy(20,3);
cout"T E L E P H O N E D I R E C T O R Y";
gotoxy(22,5);
cout
"";
gotoxy(30,6);
cout "MAIN MENU ";
gotoxy(22,7);
cout
"";
gotoxy(27,9);
cout"1. ADD RECORDS ";
gotoxy(27,10);
76
cout"2. MODIFY RECORDS ";
gotoxy(27,11);
cout"3. DELETE RECORDS ";
gotoxy(27,12);
cout"4. SEARCH RECORDS ";
gotoxy(27,13);
cout"5. REPORTS ";
gotoxy(27,14);
cout"6. EXIT ";
textcolor(WHITE);
textbackground(BLACK);
gotoxy(22,16);
cout "ENTER YOUR CHOICE..... ";
IIlush(stdin);
IIlush(stdout);
chgetch();
switch(ch)

case '1':
pers.addobject();
break;
77
case '2':
pers.modiIyobject();
break;
case '3':
pers.delobject();
break;
case '4':
pers.searchobject();
break;
case '5':
pers.reports();
break;
case '6':
clrscr();
exit(1);
deIault :
textcolor(YELLOW);
pers.box(20,19,55,21);
gotoxy(22,20);
cout " ";
gotoxy(22,20);
78
textcolor(GREEN);
cputs("\aWrong Entry Press Enter");
textcolor(WHITE);
IIlush(stdin);
IIlush(stdout);
getch();
IIlush(stdin);
IIlush(stdout);
}
}while(ch!6);
} // End oI main
79
80
CO$C)-SIO$
we discuss the manual and purposed system by which we
conclude that by using this project a lot oI man power is reduce.
In the manual system a lot oI paper work is required by which
overall cost is increase but by using this project all the work can
be handle on the computer so this project reduce the cost. In the
81
manual system no privacy is there anybody can use the data. But
in case oI computerized system secrecy will remain. In manual
system a iI there is a change in the phone no. then we have to
store all the data again by which a lot oI time, money is required
but by using this project we can easily modiIy the no. oI a
person without any redundancy so this project is very helpIul in
case oI time,money.
Data being operated manually sometimes leads to errors because
oI the skills oI the telephone board`s members writing the each
and every record or Ior some other reason. But in the case oI
computerized system there is no chance Ior that type oI error.
The output generated by the computer will be in tabulated Irom
which will be understood more clearly.
F-T-.# SCO8# OF 8.O7#CT
One thing we know that the scope oI the project depends on
the needs every thing whatever is being made or has already
been made is just because oI the need. When we Iace a situation
in which we require something which is not available with us,
we try to invent that thing. Similar is the case with our
Telephone Directory Management System. BeIore the advent
82
oI computer, we know that each and every task is being
perIormed under manual systems. It is tedious to work in the
manual system as than oI computer system. One can handle his
work very eIIiciently, speedily and timely with the help oI
computer. II the manual system were continued today then a
person would always be busy with entering, deleting and
updating the records. A computerized Telephone Directory
Management System solves this problem.
In short, a computerized Telephone Directory System oIIers
a great deal oI comIort. Everything is revolving around the
mouse button and just a click solves many problems within
seconds. No need to maintain heavy registers. There are no
requirements oI keeping big records. Everything is automatic.
.eference
While making this project I have reIerred the Iollowing books
Ior getting an idea to make this project and also Ior
understanding the complete c language the name oI the author
oI the books reIerred by me are as Iollows::
1. Object oriented programming in turbo c:
83
Robert LaIore
2. Computer science with c:
Sumita Arora
3. Object oriented programming with c:
E. Balaguruswamy.
84

You might also like