Professional Documents
Culture Documents
GOVT - Docx Anjali
GOVT - Docx Anjali
COLLEGE FOR
WOMEN
ROHTAK
A PROJECT REPORT
ON
1
ACKNOWLEDGEMENT
After an intensive period of five months today is the day writing this note
of thanks is the finishing touch on my dissertation. It has been a period of
intense learning for me, not only in the scientific area, but also on a personal
level. I would like to reflect on the people who have supported and helped me so
much throughout this period. It is with great satisfaction and pride that I present
the Project on PRISION MANAGEMENT
SYSTEM during 4th Semester, for partial fulfillment of our Master of Science
(Computer Science) degree at Government PG College for Women, Rohtak. I
am thankful to Mrs. Rohini Sharma Associate Professor, for being my
mentor in this journey. I want to thank him for excellent cooperation and for all
of the opportunities. She provided me an excellent atmosphere for doing
research. I am also thank to HOD Mrs. NISHA MALIK for being a constant
source os inspiration and motivation during the course of the report. Last but not
the least, I want to acknowledge the contribution of my parents and family
member for their constant motivation, inspiration and their belief in me that I
could make it happen.
2
CONTENT
1. Chapter: INTRODUCTION
2. CHAPTER: ABOUT THE LANGUAGE USED
a. ADVANTAGES OF COMPUTER SYSTEM
b. DISADVANTAGES OF THE MANUAL SYSTEM
3. CHAPTER: SYSTEM ANALYSIS
4. CHAPTER: SYSTEM DESIGN
a) INPUT DESIGN
b) OUTPUT DESIGN
c) SYSTEM CONFIGURATION
d) MINIMUM REQUIREMENT
5. CHAPTER: CODING
6. CHAPTER: OUTPUT OF THE PROJECT
7. CHAPTER: CONCLUSION & RECOMMENDATION
3
About the language used
HISTORY OF C PROGRAMMING LANGUAGE
Evolution of C programming language C has often been termed as a "Pseudo high level
language" or a "Middle level language" by many programmers. This is not because of its lack
of programming power but because of its capability to access the system's low level
functions. In fact C was invented specifically to implement UNIX. C instructions are
compiled to assembly code, therefore, depending on the complexity of the code and on the
compiler optimization capabilities, C code may run as fast as assemby. Ken Thompson
created the B language in 1969 from Martin Richard's BCPL (Basic Combined Programming
Language). He used assembly language and B to produce the initial versions of the UNIX
operating system. BCPL and B were typeless languages in which variables were simply
words in memory. Dennis Ritchie of Bell Laboratories later converted B into C by retaining
most of B's syntax in 1972 and wrote the first compiler. This was implemented on DEC's
PDP 11 and it was first used as the system's language for rewriting the UNIX operating
system. Later on, UNIX, its tools and C grew simultaneously. In 1978, Kernighan and Ritchie
wrote a book entitled 'The C Programming Language' that became the language definition for
almost a decade. Beginning in 1983, the ANSI X3J11 committee was asked to standardize the
C language. The result was ANSI C, a standard which was adopted in 1988. It is not forced
upon any programmer, but since it is so widely accepted, it would be economically unwise
for any systems programmer or compiler writer not to conform to the standard. Features of C
Language · C is a procedure-based programming language. This means the program is
viewed as a means to solve a problem. Various functions modules or code blocks are thus,
written to solve this problem. · C functions can accept parameters and return values and
perform variety of tasks like input from the user, displaying the information, etc. · C is simple
and easy to learn and use. The main components like built in functions, operators, keywords
are small in number. · In C, errors are checked only at compile time. The compiled code
though have no safety checks for bad type casts, bad array indices, or bad pointers. · C works
best for small projects where performance is important. · C contains the capability of
assembly language with the features of high level language which can be used for creating
software packages, system software etc. · C is highly portable. C programs written on one
computer can run on other computer without making any changes in the program. ; Uses of C
C's wide acceptance and efficiency is the reason why libraries of several other applications
are often implemented in C. Some of the applications using C in its kernels are: Uses of C are
many in addition to Systems programming. Some of which are as follows : o Language
compilers and interpreters o Device drivers o Telecom applications o Network programming
o Digital Signal processing applications o Database applications o Text editors Compilers
available Most flavors of UNIX operating system have a C compiler. So if a student has
access to an UNIX system, he or she can straight away start coding and compiling C sample
programs and exercises given in this course. With respect to personal computers , Microsoft
C for IBM PC's and compatibles or Borland C are the two most commonly used
programming environments. There are a number of free C compilers available on the web for
installation on the PC, one can use them as HISTORY OF C PROGRAMMING
4
LANGUAGE Evolution of C programming language C has often been termed as a "Pseudo
high level language" or a "Middle level language" by many programmers. This is not because
of its lack of programming power but because of its capability to access the system's low
level functions. In fact C was invented specifically to implement UNIX. C instructions are
compiled to assembly code, therefore, depending on the complexity of the code and on the
compiler optimization capabilities, C code may run as fast as assemby. Ken Thompson
created the B language in 1969 from Martin Richard's BCPL (Basic Combined Programming
Language). He used assembly language and B to produce the initial versions of the UNIX
operating system. BCPL and B were typeless languages in which variables were simply
words in memory. Dennis Ritchie of Bell Laboratories later converted B into C by retaining
most of B's syntax in 1972 and wrote the first compiler. This was implemented on DEC's
PDP 11 and it was first used as the system's language for rewriting the UNIX operating
system. Later on, UNIX, its tools and C grew simultaneously. In 1978, Kernighan and Ritchie
wrote a book entitled 'The C Programming Language' that became the language definition for
almost a decade. Beginning in 1983, the ANSI X3J11 committee was asked to standardize the
C language. The result was ANSI C, a standard which was adopted in 1988. It is not forced
upon any programmer, but since it is so widely accepted, it would be economically unwise
for any systems programmer or compiler writer not to conform to the standard. Features of C
Language · C is a procedure-based programming language. This means the program is
viewed as a means to solve a problem. Various functions modules or code blocks are thus,
written to solve this problem. · C functions can accept parameters and return values and
perform variety of tasks like input from the user, displaying the information, etc. · C is simple
and easy to learn and use. The main components like built in functions, operators, keywords
are small in number. · In C, errors are checked only at compile time. The compiled code
though have no safety checks for bad type casts, bad array indices, or bad pointers. · C works
best for small projects where performance is important. · C contains the capability of
assembly language with the features of high level language which can be used for creating
software packages, system software etc. · C is highly portable. C programs written on one
computer can run on other computer without making any changes in the program. ; Uses of C
C's wide acceptance and efficiency is the reason why libraries of several other applications
are often implemented in C. Some of the applications using C in its kernels are: Uses of C are
many in addition to Systems programming. Some of which are as follows : o Language
compilers and interpreters o Device drivers o Telecom applications o Network programming
o Digital Signal processing applications o Database applications o Text editors Compilers
available Most flavors of UNIX operating system have a C compiler. So if a student has
access to an UNIX system, he or she can straight away start coding and compiling C sample
programs and exercises given in this course. With respect to personal computers , Microsoft
C for IBM PC's and compatibles or Borland C are the two most commonly used
programming environments. There are a number of free C compilers available on the web for
installation on the PC, one can use them well.
5
About C Language
The C Language is developed by Dennis Ritchie for creating system applications that directly
interact with the hardware devices such as drivers, kernels, etc.
C programming is considered as the base for other programming languages, that is why it is
known as mother language.
1. Mother language
2. System programming language
3. Procedure-oriented programming language
4. Structured programming language
5. Mid-level programming language
1) C as a mother language
C language is considered as the mother language of all the modern programming languages
because most of the compilers, JVMs, Kernels, etc. are written in C language, and most
of the programming languages follow C syntax, for example, C++, Java, C#, etc.
It provides the core concepts like the array, strings, functions, file handling, etc. that are being
used in many languages like C++, Java, C#, etc.
It can't be used for internet programming like Java, .Net, PHP, etc.
3) C as a procedural language
A procedure is known as a function, method, routine, subroutine, etc. A procedural
language specifies a series of steps for the program to solve the problem.
A procedural language breaks the program into functions, data structures, etc.
6
C is a procedural language. In C, variables and function prototypes must be declared before
being used.
In the C language, we break the program into parts using functions. It makes the program
easier to understand and modify.
A High-Level language is not specific to one machine, i.e., machine independent. It is easy
to understand.
Standard of c language
ANSI C and ISO C edit
Main article: ANSI C
During the late 1970s and 1980s, versions of C were implemented for a wide variety
of mainframe computers, minicomputers, and microcomputers, including the IBM PC, as its
popularity began to increase significantly.
In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to
establish a standard specification of C. X3J11 based the C standard on the Unix
implementation; however, the non-portable portion of the Unix C library was handed off to
the IEEE working group 1003 to become the basis for the 1988 POSIX standard. In 1989, the
C standard was ratified as ANSI X3.159-1989 "Programming Language C". This version of
the language is often referred to as ANSI C, Standard C, or sometimes C89.
In 1990, the ANSI C standard (with formatting changes) was adopted by the International
Organization for Standardization (ISO) as ISO/IEC 9899:1990, which is sometimes called
C90. Therefore, the terms "C89" and "C90" refer to the same programming language.
ANSI, like other national standards bodies, no longer develops the C standard independently,
but defers to the international C standard, maintained by the working group ISO/IEC
JTC1/SC22/WG14. National adoption of an update to the international standard typically
occurs within a year of ISO publication.
7
One of the aims of the C standardization process was to produce a superset of K&R C,
incorporating many of the subsequently introduced unofficial features. The standards
committee also included several additional features such as function prototypes (borrowed
from C++), void pointers, support for international character sets and locales, and
preprocessor enhancements. Although the syntax for parameter declarations was augmented
to include the style used in C++, the K&R interface continued to be permitted, for
compatibility with existing source code.
C89 is supported by current C compilers, and most modern C code is based on it. Any
program written only in Standard C and without any hardware-dependent assumptions will
run correctly on any platform with a conforming C implementation, within its resource limits.
Without such precautions, programs may compile only on a certain platform or with a
particular compiler, due, for example, to the use of non-standard libraries, such
as GUI libraries, or to a reliance on compiler- or platform-specific attributes such as the exact
size of data types and byte endianness.
In cases where code must be compatible by either standard-conforming or K&R C-based
compilers, the __STDC__ macro can be used to split the code into Standard and K&R sections
to prevent the use on a K&R C-based compiler of features available only in Standard C.
After the ANSI/ISO standardization process, the C language specification remained relatively
static for several years. In 1995, Normative Amendment 1 to the 1990 C standard (ISO/IEC
9899/AMD1:1995, known informally as C95) was published, to correct some details and to
add more extensive support for international character sets.[22]
C99edit
Main article: C99
The C standard was further revised in the late 1990s, leading to the publication of ISO/IEC
9899:1999 in 1999, which is commonly referred to as "C99". It has since been amended three
times by Technical Corrigenda.[23]
C99 introduced several new features, including inline functions, several new data
types (including long int and a complex type to represent complex numbers), variable-
length arrays and flexible array members, improved support for IEEE 754 floating point,
support for variadic macros (macros of variable arity), and support for one-line comments
beginning with //, as in BCPL or C++. Many of these had already been implemented as
extensions in several C compilers.
C99 is for the most part backward compatible with C90, but is stricter in some ways; in
particular, a declaration that lacks a type specifier no longer has int implicitly assumed. A
standard macro __STDC_VERSION__ is defined with value 199901L to indicate that C99
support is available. GCC, Solaris Studio, and other C compilers now support many or all of
the new features of C99. The C compiler in Microsoft Visual C++, however, implements the
C89 standard and those parts of C99 that are required for compatibility with C++11.[24][needs
update]
In addition, the C99 standard requires support for identifiers using Unicode in the form of
escaped characters (e.g. \u0040 or \U0001f431) and suggests support for raw Unicode
names.
C11edit
Main article: C11 (C standard revision)
8
In 2007, work began on another revision of the C standard, informally called "C1X" until its
official publication of ISO/IEC 9899:2011 on 2011-12-08. The C standards committee
adopted guidelines to limit the adoption of new features that had not been tested by existing
implementations.
The C11 standard adds numerous new features to C and the library, including type generic
macros, anonymous structures, improved Unicode support, atomic operations, multi-
threading, and bounds-checked functions. It also makes some portions of the existing C99
library optional, and improves compatibility with C++. The standard
macro __STDC_VERSION__ is defined as 201112L to indicate that C11 support is available.
C17edit
Main article: C17 (C standard revision)
Published in June 2018 as ISO/IEC 9899:2018, C17 is the current standard for the C
programming language. It introduces no new language features, only technical corrections,
and clarifications to defects in C11. The standard macro __STDC_VERSION__ is defined
as 201710L to indicate that C17 support is available.
C23edit
Main article: C23 (C standard revision)
C23 is the informal name for the next (after C17) major C language standard revision. It was
informally known as "C2X" through most of its development. C23 is expected to be
published in early 2024 as ISO/IEC 9899:2024.[25] The standard macro __STDC_VERSION__ is
defined as 202311L to indicate that C23 support is available.
C2Yedit
C2Y is a temporary informal name for the next major C language standard revision, after C23
(C2X), that is hoped to be released later in the 2020s decade, per the two in "C2Y". An early
working draft of C2Y was released in February 2024 as N3220 by the working
group ISO/IEC JTC1/SC22/WG14.
9
Features of C Language
C is the widely used language. It provides many features that are given below.
1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible
10
Features of C Programming
1) Simple
C is a simple language in the sense that it provides a structured approach (to break the
problem into parts), the rich set of library functions, data types, etc.
5) Rich Library
C provides a lot of inbuilt functions that make the development fast.
6) Memory Management
It supports the feature of dynamic memory allocation. In C language, we can free the
allocated memory at any time by calling the free() function.
8) Pointer
C provides the feature of pointers. We can directly interact with the memory by using the
pointers. We can use pointers for memory, structures, functions, array, etc.
11
9) Recursion
In C, we can call the function within the function. It provides code reusability for every
function. Recursion enables us to use the approach of backtracking.
10) Extensible
C language is extensible because it can easily adopt new features.
#include <stdio.h>
int main()
{
printf(“Hello, World!\n”);
return 0;
}
In this program:
#include <stdio.h>: This line includes the standard input/output library, which
provides the printf function for printing text to the console.
int main(): This is the main function where the program execution begins.
The int before main indicates that the function returns an integer value.
{}: The curly braces define the scope of the main function. Inside these braces, we
write the code that the function executes.
printf("Hello, World!\n");: This line uses the printf function to display the text “Hello,
World!” followed by a newline character (\n) to the console.
return 0;: Finally, the return 0; statement indicates that the program has terminated
successfully. The value 0 is typically used to indicate success, while non-zero values
can indicate errors.
Compile and run this program, and you’ll see the familiar “Hello, World!” message
displayed on your screen.
12
1. Basic Data Types
These data types allow C programmers to declare variables, define functions, and manage
memory efficiently.
13
Functions
Functions are blocks of code that perform a specific task. They allow you to break your
program into smaller, manageable pieces, making it more organized and easier to maintain. In
C, every program must have a main function, which serves as the entry point to the program.
Loops are used in programming to execute a block of code repeatedly until a certain
condition is met. C provides three main types of loops:
14
1. for loop
The for loop is used when you know the number of iterations you want to perform. It
consists of three parts: initialization, condition, and increment or decrement.
2. while Loop
The while loop is used when you want to execute a block of code as long as a certain
condition is true.
3. do-while Loop
The do-while loop is similar to the while loop, but it guarantees that the code block is
executed at least once before checking the condition.
2. if-else statement: The if-else statement is used to execute one block of code if a
condition is true and another block of code if the condition is false.
3. switch statement: The switch statement is used to select one of many code blocks to be
executed.
Application of C Programming
C programming has a wide range of applications across various domains. Here
are some notable areas where C is commonly used:
2. Application Software
C is used to build a variety of application software, such as text editors,
compilers, and databases. It provides the necessary tools and efficiency to create
robust and performance-critical applications.
3. Game Development
Many video games and game engines are developed in C or C++. These
languages offer the performance and control needed for real-time rendering and
complex game logic.
15
4. Embedded Systems
C is widely used in the development of embedded systems found in consumer
electronics, automotive systems, medical devices, and more. Its ability to work
with limited resources makes it a preferred choice in this domain.
5. Scientific Computing
C is used in scientific research and computational modeling due to its efficiency
in handling complex calculations. Researchers often use C for simulations, data
analysis, and scientific programming.
1. It is easy to understand
One of the main reasons why people choose C over other programming
languages is its simplicity. C is a highly portable language as programs coded
in it are far more fast and efficient. This makes learning C easier than any other
programming language. You can easily grasp the concepts behind C because
there aren't many keywords or symbols involved. In addition, you don't need to
be an expert in computer science to get started with C programming. All you
have to do is take a few tutorials/ courses online and start writing your own
codes. Also, there are system-generated functions and user-defined functions in
C Language.
16
2. Presence of many Libraries
3. Easy to write
4. Low cost
If you want to execute your application quickly, then C is probably the right
choice for you. Since C uses fewer instructions, it executes faster than other
programming languages such as Java, Ruby, PHP, etc.
6. Portable
9. Speed of Compilation
The C compiler produces machine code very fast. Close to a thousand lines of
code can be put together in a couple of seconds. The C Compiler makes the
code more efficient for faster execution.
18
this feature makes us more flexible than other languages like Java where we
must declare all variables as final.
C is a very vast and powerful language and simply follows the procedural
programming approach. It doesn't extend its support to the concept of OOPs
(Inheritance, Polymorphism, Encapsulation, Abstraction, Data Hiding). Here,
you can't create a class with multiple inheritances like Java, Python, or C++. In
OOP languages like Java, we can inherit methods from the parent class. But
there is nothing similar in the C language. We cannot create subclasses for our
classes. So it makes it difficult to reuse existing codes.
3. No Garbage Collection
19
when there is insufficient free space on the heap to allocate new objects; this
may occur because all available physical RAM was allocated to other processes
running on the computer system. Manual garbage collection involves explicitly
freeing unused blocks of memory with calls to functions such as malloc.
4. Run-time checking
In the C programming language, the errors are not detected after each line of
code. The compiler shows all the errors in the code only during the run-time of
the whole which makes the checking of code (debugging) exceptionally
complex in enormous projects.
Also, the compiler doesn't check whether a variable was declared before its use.
The programmer must remember this rule while writing programs.
20
7. Lacks Constructor and Destructor
21
Front-end & Backend used
22
ADVANTAGES OF THE COMPUTERIZED SYSTEM
3. Data can be stored in floppies or magnetic discs which are very compact.
5. Any report (if necessary) can be generated much easily with slight
various books.
9. New reports can be generated easily when required, with only sight
very difficult.
23
2. To maintain the records i.e. to add, find & delete the records manually is
SYSTEM DESIGN
The computer approach in an interactive system that accepts inputs options and
provide the user with data and information. The main feature of this system is:
1. The user, using a CRT display device, uses system interactively.
3. Care has been taken to keep the user’s input simple to ensure accuracy of
input.
24
4. The output is presented in a well designed from by proper
formatting.
5. Subroutines have been implemented in the program to facilitate editing
and modifications.
functions.
Dialogue Design:
Keeping in view user’s requirements, a number of dialogues have been designed
which help and guide the user wherever required. Such an arrangement helps in
an efficient communication between the user and the system. The main features
of the dialogues are:
a) Different types of dialogues have been designed for
25
e) The dialogues are of leading type, which encourage
user’s response.
Input Design :
Since the system is used interactively, it has two types of inputs. Interactive
input which is the point of contact of the user with the system, and input to the
internal system i.e. data files.Data files are stored on the hard disk because it
provides quick access to data files. Files are created on-line and modification
and verification can be done easily.
File Design :
One should keep in mind the following points before attempting to design a
file for any system:
c) The mode of storing the data in order to have high package density.
26
d) The mode of storing information in order to achieve fast response
time.
The response time of magnetic disk is very low and a large number of
updating can be performed easily. In this project floppy disks and hard
disks pack have been used.
Processing of files:
To get the output, program is loaded from hard disk and then run in dbase
IV. Processing of files is divided into four parts:
a) appendage: the data in the file created already is appended one by one
b) Viewing: to view data stored, file name is entered, file is opened, and
c) Updating: to update data, file name is required. On entering file name, old
update/add/delete.
d) Output: to get the output, the first thing is to choose the option, respective
file is opened, data are read, conversions are made and finally the output
is displayed on screen/printer.
Output Design :
27
The outputs have been designed so as to enhance readability
and uniformity. The outputs are taken on CRT and/or the
printer. The format of the CRT screen uses 80* 25 size i.e.
eighty characters per used uses both 80 characters and 132
characters paper for output.
Implementation:
Implementation is the stage of the project when the theoretical design is turned
in to working system. If the implementation storage is not carefully planned and
controlled, There may be problems. This can be considered as the crucial stage
in achieving a successful system and give user the confidence that the new
system will work and be effective. The system designed is implemented on Intel
–I5 processor.
SYSTEM CONFIGURATION
iii) Keyboard
iv) Printer
v) Operating system
vi) software
28
c) One Hard Disk of 1TB
iii) Keyboard
iv) Printer
b) Speed: 20 PPM
v) Operating system
a) Window 7
vi) IDE software
29
MINIMUM REQUIREMENT
COMPONENTS
iii) Keyboard
iv) Printer
v) Operating system
ii) LED
iii) Keyboard
a) Keyboard of 104 keys
iv)Printer
a) Type: Laser printer (for Laser Printing)
b) Speed: 20ppm
v) Operating system
30
a) DOS
b) Window
c) Linux , Unix
31
EXISTING SYSTEM
The existing system depends upon manual operation i.e. report work kept in
simple files, maintain the data but any small mistake can lead to a big problem.
For example to check the existence of any customer or the fee record in
the hotel can be done by the help of computers much easily rather manually.
Other drawbacks in the existing system are: ---
Searching for a particular record in the collected records becomes very difficult.
To maintain the records i.e. to modify, add & delete the records manually is a
very difficult task and also not neat and clean. Due to the mathematically
calculations in the fine amount may cause trouble many times manually. A large
group of staff is employed. Mathematical calculation involved may be error
prone. The whole process is time consuming. Inconvenience is caused to any
customer.
It is very difficult to carry and store all the registers relating to customer
information’s and Bill. All of them in the form of paper documents.
Record keeping is quite difficult.
32
CODING
OUTPUT
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
void addrecord();
void viewrecord();
void editrecord();
void searchrecord();
void deleterecord();
void login();
struct record
33
{
char id[10];
char name[30];
char age[6];
char gender[10];
char weight[20];
char height[20];
char haircolor[20];
char eyecolor[20];
char crime[40];
char convictedf[20];
char court[20];
char lawyer[20];
char punishment[50];
char punishments[20];
char punishmente[20];
34
char emergencyc[20];
char emergencyr[20];
char emergencyn[20];
} a;
int main()
login();
int ch;
printf("\n\n\t***********************************\n");
printf("\t\t*PRISONER RECORD*\n");
printf("\t***********************************");
while(1)
printf("\n\n\t\tMAIN MENU:");
printf("\n\n\tADD RECORD\t[1]");
printf("\n\tSEARCH RECORD\t[2]");
printf("\n\tEDIT RECORD\t[3]");
printf("\n\tVIEW RECORD\t[4]");
printf("\n\tDELETE RECORD\t[5]");
printf("\n\tEXIT\t\t[6]");
35
scanf("%d",&ch);
switch(ch)
case 1:
addrecord();
break;
case 2:
searchrecord();
break;
case 3:
editrecord();
break;
case 4:
viewrecord();
break;
case 5:
deleterecord();
break;
case 6:
system("cls");
printf("\n\n\t\tTHANK YOU FOR USING THIS SOFTWARE \n\t\t THIS PROJECT IS BROUGHT TO YOU
BY code-projects.or
getch();
exit(0);
36
default:
getch();
break;
system("cls");
return 0;
//*********************************************************
//*********************************************************
void addrecord( )
system("cls");
FILE *fp ;
char filename[30];
int choice;
printf("\n\n\t\t***************************\n");
37
printf("\n\t\t***************************\n\n");
fflush(stdin);
gets(filename);
if ( fp == NULL )
fp=fopen("filename","wb+");
if(fp==NULL)
printf("\nSYSTEM ERROR...");
getch();
return ;
choice=0;
fflush(stdin);
scanf("%s",id);
38
rewind(fp);
while(fread(&a,sizeof(a),1,fp)==1)
if(strcmp(a.id,id)==0)
choice=1;
if(choice==0)
strcpy(a.id,id);
fflush(stdin);
gets(a.name);
gets(a.gender);
fflush(stdin);
gets(a.age);
fflush(stdin);
39
printf("\tENTER WEIGHT: ");
gets(a.weight);
fflush(stdin);
gets(a.height);
fflush(stdin);
gets(a.haircolor);
fflush(stdin);
gets(a.eyecolor);
fflush(stdin);
gets(a.crime);
fflush(stdin);
gets(a.convictedf);
fflush(stdin);
gets(a.court);
fflush(stdin);
gets(a.lawyer);
fflush(stdin);
40
printf("\tENTER CONVICTION: ");
gets(a.punishment);
fflush(stdin);
gets(a.punishments);
fflush(stdin);
gets(a.punishmente);
fflush(stdin);
gets(a.emergencyc);
fflush(stdin);
gets(a.emergencyr);
fflush(stdin);
gets(a.emergencyn);
fflush ( stdin ) ;
41
another = getch( ) ;
fclose ( fp ) ;
getch();
//***********************************************************
//***********************************************************
void searchrecord( )
system("cls");
FILE *fp ;
char id[16],choice,filename[14];
int ch;
printf("\n\n\t\t*******************************\n");
printf("\n\t\t*******************************\n\n");
do
fflush(stdin);
42
gets(filename);
//system("cls");
gets(id);
system("cls");
//{
if(strcmpi(a.id,id)==0)
{ printf("\n");
43
printf("\nPRISONER'S EMERGENCY CONTACT IS: %s",a.emergencyc);
printf("\n");
// }
fflush(stdin);
scanf("%c",&choice);
while(choice=='Y'||choice=='y');
fclose ( fp) ;
getch();
return ;
getch();
//*********************************************************
//*********************************************************
void editrecord()
44
system("cls");
FILE *fp ;
char id[10],choice,filename[14];
int num,count=0;
printf("\n\n\t\t*******************************\n");
printf("\n\t\t*******************************\n\n");
do
fflush(stdin);
gets(filename);
printf("\n\tENTER ID:");
gets(id);
/*if ( fp == NULL )
getch();
return;
}*/
45
while ( fread ( &a, sizeof ( a ), 1, fp ) == 1 )
if(strcmp(a.id,id)==0)
printf("\nCOURT: %s",a.court);
46
printf("\n1.NAME.");
printf("\n2.GENDER.");
printf("\n3.AGE.");
printf("\n4.WEIGHT.");
printf("\n5.HEIGHT.");
printf("\n6.HAIRCOLOR.");
printf("\n7.EYECOLOR.");
printf("\n8.CRIME.");
printf("\n10.COURT.");
printf("\n11.LAWYER.");
printf("\n12.CONVICTION.");
printf("\n15.EMERGENCY CONTACT.");
printf("\n18.WHOLE RECORD.");
do
fflush(stdin);
scanf("%d",&num);
fflush(stdin);
switch(num)
47
case 1:
printf("\nNAME:");
gets(a.name);
break;
case 2:
printf("\nGENDER:");
gets(a.gender);
break;
case 3:
printf("\nAGE:");
gets(a.age);
break;
case 4:
printf("\nWEIGHT:");
gets(a.weight);
break;
case 5:
printf("\nHEIGHT:");
gets(a.height);
break;
case 6:
48
printf("ENTER THE NEW DATA:");
printf("\nHAIRCOLOR:");
gets(a.haircolor);
break;
case 7:
printf("\nEYECOLOR:");
gets(a.eyecolor);
break;
case 8:
printf("\nCRIME:");
gets(a.crime);
break;
case 9:
printf("\nPLACE:");
gets(a.convictedf);
break;
case 10:
printf("\nCOURT:");
gets(a.court);
break;
case 11:
49
printf("\nLAWYER:");
gets(a.lawyer);
break;
case 12:
printf("\nCONVICTION:");
gets(a.punishment);
break;
case 13:
gets(a.punishments);
break;
case 14:
gets(a.punishmente);
break;
case 15:
printf("\nEMERGENCY CONTACT:");
gets(a.emergencyc);
break;
case 16:
50
gets(a.emergencyr);
break;
case 17:
gets(a.emergencyc);
break;
case 18:
printf("\tPRISONER NAME:");
gets(a.name);
printf("\tGENDER:");
gets(a.gender);
printf("\tAGE:");
gets(a.age);
printf("\tWEIGHT:");
gets(a.weight);
printf("\tHEIGHT:");
gets(a.height);
printf("\tHAIRCOLOR:");
gets(a.haircolor);
printf("\tEYECOLOR:");
gets(a.eyecolor);
printf("\tCRIME:");
gets(a.age);
gets(a.convictedf);
printf("\tCOURT:");
gets(a.court);
51
printf("\tLAWYER:");
gets(a.lawyer);
printf("\tCONVICTION:");
gets(a.punishment);
gets(a.punishments);
gets(a.punishmente);
gets(a.emergencyc);
gets(a.emergencyr);
gets(a.emergencyn);
break;
case 19:
getch();
return ;
break;
default:
break;
while(num<1||num>20);
52
fseek(fp,-sizeof(a),SEEK_CUR);
fwrite(&a,sizeof(a),1,fp);
fseek(fp,-sizeof(a),SEEK_CUR);
fread(&a,sizeof(a),1,fp);
choice=5;
break;
if(choice==5)
system("cls");
printf("\n\t\tEDITING COMPLETED...\n");
printf("--------------------\n");
printf("--------------------\n");
53
printf("\nPRISONER'S EYECOLOR IS: %s",a.eyecolor);
fclose(fp);
scanf("%c",&choice);
count++;
else
scanf("%c",&choice);
while(choice=='Y'||choice=='y');
fclose ( fp ) ;
54
printf("\tPRESS ENTER TO EXIT EDITING MENU.");
getch();
//*********************************************************
//*********************************************************
void viewrecord()
system("cls");
FILE *fp;
//struct record a;
char filename[30];
printf("\n\n\t\t***************************\n");
printf("\n\t\t***************************\n\n");
fp=fopen("filename","rb");
rewind(fp);
while((fread(&a,sizeof(a),1,fp))==1)
55
printf("\nPRISONER'S HAIRCOLOR IS: %s",a.haircolor);
getch();
printf("\n\n");
fclose(fp);
getch();
//*********************************************************
//*********************************************************
void deleterecord( )
system("cls");
56
FILE *fp,*ft ;
int choice,check;
int j=0;
char pass[8];
printf("\n\n\t\t*************************\n");
printf("\n\t\t*************************\n\n");
printf("\nENTER PASSWORD\n");
int i;
for( i=0;i<4;i++)
pass[i]=getch();
printf("*");
if (strcmpi(pass,"pass")==0)
printf("\n\t\t*ACCESS GRANTED*\n\n");
fflush(stdin);
gets(filename);
if ( fp == NULL )
57
{
getch();
return ;
ft=fopen("temp","wb");
if(ft==NULL)
printf("\nSYSTEM ERROR");
getch();
return ;
fflush(stdin);
gets(id);
while(fread(&file,sizeof(file),1,fp)==1)
if(strcmp(file.id,id)!=0)
fwrite(&file,sizeof(file),1,ft);
fclose(ft);
fclose(fp);
remove("filename");
58
rename("temp","filename");
printf("\nDELETED SUCCESFULLY...");
getch();
fflush(stdin);
scanf("%c",&another);
getch();
else
printf("\nSorry!Invalid password\n");
exit(0);
void login()
int a=0,i=0;
char pword[10],code[10];
char user[10]="user";
char pass[10]="pass";
do
59
{
scanf("%s", &uname);
while(i<10)
pword[i]=getch();
c=pword[i];
if(c==13) break;
else printf("*");
i++;
pword[i]='\0';
//char code=pword;
i=0;
//scanf("%s",&pword);
break;
else
a++;
60
getch();//holds the screen
while(a<=2);
if (a>2)
printf("\nSorry you have entered the wrong username and password for four times!!”)
printf("\nSorry you
getch();
system("cls");
61
OUTPUTS
62
Main menu:
63
ADD RECORD
64
ADD RECORD
65
ADD RECORD
66
ADD RECORD
67
68