Mini Project in C Employee Record System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

ABSTRACT

This is a very simple mini project in C Employee Record System. In this project, you can
manage employee records – add, list, modify and delete records. Understanding this
project will help you learn how to add, view, change and remove data using file
handling.
Here, you can list the employees’ record but cannot search it like in other C projects. Try
modifying this project, and write your own code to implement the search function. This
project is complete and totally error-free.
This project is a console application without graphics compiled in Code::Blocks using GCC
compiler.The source code for this project is short, simple and easy to understand.
Running Employee Record management system on other compiler platforms may
require modifications to the code, and the current code will show errors.

Page I
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany the successful completion of any task
would be impossible without the mention of the people who made it possible, whose
constant guidance and encouragement crowned our efforts with success.

I have great pleasure in expressing gratitude to Dr. Mohan Manghnani, Chairman of


New Horizon Educational Institutions for providing necessary infrastructure and creating
good environment.

I take this opportunity to express my profound gratitude to Dr. Manjunatha,Principal


NHCE, for his constant support and encouragement.

I am grateful to Dr.Prashanth C.S.R, Dean Academics, for his unfailing encouragement


and suggestions, given to me in the course of my project work.

I would also like to thank Dr. B. Rajalakshmi, Professor and Head, Department of
Computer Science and Engineering, for her constant support.

I express my gratitude to Mr./Ms./Dr.Faculty Name,Designation, my project guide, for


constantly monitoring the development of the project and setting up precise deadlines.
Her valuable suggestions were the motivating factors in completing the work.

DENCY SANGANI
1NH18AU012

Page II
CONTENTS

ABSTRACT I
ACKNOWLEDGEMENT II
LIST OF FIGURES IV
1. INTRODUCTION V
1.1. PROBLEM DEFINITION V
1.2. OBJECTIVES V
1.3. METHODOLOGY TO BE FOLLOWED V
1.4. EXPECTED OUTCOMES V
1.5. HARDWARE AND SOFTWARE REQUIREMENTS VI
2. DATASTRUCTURES VII
2.1. STACK IX
2.2. QUEUES IX
2.3. LINKED LIST IX
2.4. TREES XI
2.5. GRAPHS XII
2.6. FILES XII
3. DESIGN XIII
3.1. FLOWCHART XIII
3.2. ALGORITHM/PSEUDOCODE XIV
4. IMPLEMENATION XVII
4.1. MODULE 1 FUNCTIONALITY XVII
4.2. MODULE 2 FUNCTIONALITY XVII
4.3. MODULE 3 FUNCTIONALITY XVII
4.4. MODULE 4 FUNCTIONALITY XVII
4.5. MODULE 5 FUNCTIONALITY XVII
4.6. MODULE 6 FUNCTIONALITY XVII
5. RESULTS XVIII
6. CONCLUSION XVIII
7. REFERENCES XVIII

Page III
LIST OF FIGURES

Fig. No Figure Description Page No

2.4 Linked Lists X

2.6 File Handling XII

Page IV
1.INTRODUCTION
1.1 PROBLEM DEFINATION
Every organization pays salary to its employees. This work is done every month and the
record of this activity is kept for further use. The work of the salary payment is very
important for the organization. So this area is to be computerized to make process easy,
quick, secure and reliable. Thus a secured and reliable system is required to handle it.
Automation of salary payment system, as described above, can lead to a error free,
secure and fast information system.
It can assist the staff to concentrate on other activities rather to concentrate on record
keeping. Thus it will help the organization in better utilization of resources. The
organization can maintain computerized record without redundant entries that means
that one need not be distracted by information that is not relevant much more quickly.

1.2 OBJECTIVES
• To keep and manipulate the details of all the employees in company.
• To generate enquiry of employee on demand.
• To keep record of salary to be paid for each grade employee.
• To keep details of salary paid to employee.
• To keep details of fund given to the employee.
• To calculate the employee with leave and without leave.
• To make enquiry of salary paid to employees in a given month.
• To make entry and enquiry of the fund paid to employees.
• To print details of employee not taken salary on a given month.
• To show salary slip and report of the salary paid to the employees.

1.3 METHODOLOGY TO BE FOLLOWED


Run the program and enter the employee details, it will be saved in a linked list
according to the employees. we can modify, display or delete the nodes. It will also
calculate the salary of each employee according to the information provided among
monthly salary or fixed salary.

1.4 EXPECTED OUTCOMES


Major inputs:
• Employee details
• Details of employee taken or not taken salary for a given month.
• Fund type that organisation provides.
• Salary detail.

Page V
Major outputs:
• Employee enquiry
• Details of salary of employee.
• Reports of fund given to particular employee.

1.5 HARDWARE AND SOFTWARE REQUIREMENTS


Hardware
• Processor : Any above 500 MHz
• RAM: 500 MB
• Hard disk : 5 GB
• Input Device : Standard Keyboard and mouse
• Output Device : VGA and High-Resolution Monitor
Software
• Operating System : Windows 10(Recommended)
• Compiler : Turbo C++ / Dev++

Page VI
2. DATA STRUCTURES
The logical or mathematical of a particular organisation of data is called data structure.
Objectives of data structure :
• To identify and create useful mathematical entities and operations for the
problem which need to be solved.
• Determine the representation of entities and implementation of operations
on these problems.
Data structure represents the knowledge of data to be organised in memory. It should
be designed and implemented in such a way that it reduces the complexity and
enhances the efficiency.

Classification of data structure :


Data structure is normally divided into 2 broad categories :
1.Primitive Data Structure
2.Non-primitive Data Structure

Primitive data structure


• The primitive data structures are the basic structures and are directly operated
upon by the user instructions.
• These are having different representation in different computers.i.e. integer
takes 2 bytes in memory in a 16- bit compiler whereas in 32- bit compiler it takes
4 bytes.
• Examples of primitive data structure are integer, float, char, pointers.

Page VII
Non - primitive Data Structure
• The non-primitive data structure are derived from primitive data structures.
• The non-primitive data structure emphasize an structuring of a group of
homogeneous or heterogeneous data items.
• For the non-primitive data structure the memory for a data get allocated as per
the user requirement.
• Example are array,linked list,files.

Linear Non-linear
In linear data structure the data items are In non-linear data structure the data items
arranged in a linear sequence. are not arranged in a linear sequence.
Eg: Array,Linked list Eg: Tree,Graph.

Homogeneous Non-homogeneous
In homogeneous data structure all the In non-homogeneous data structure the
elements are of same type. elements are may or may not be of same
Eg: Array type.
Eg: records

Static Dynamic
Static structures are ones whose size and Dynamic structures are one which expand
structures associated memory locations or shrink as required during program
are fixed at compile time. execution and their associated memory
Eg: Array locations change.
Eg: linked list created using linked list.
Data structure operations :
Large number of operations can be performed on data structure. Some of the important
operations are :
1. Creating : Creation of data structure.
2. Inserting : New items are added to the data structure.
3. Updating : modify the data.
4. Traversing : visiting each data element once in a given data.
5. Searching : search for a given data structure.
6. Deleting : removing an item in data structure.
7. Sorting : arrangement of data elements in given data structure.

Page VIII
2.1 ARRAYS
C programming language provides a data structure called the array, which can store a
fixed-size sequential collection of elements of the same type. An array is used to store a
collection of data, but it is often more useful to think of an array as a collection of
variables of the same type.
Instead of declaring individual variables, such as number0, number1, ..., and number99,
you declare one array variable such as numbers and use numbers[0], numbers[1], and
..., numbers[99] to represent individual variables. A specific element in an array is
accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to
the first element and the highest address to the last element.

2.2 STACKS
A stack is an Abstract Data Type (ADT), commonly used in most programming languages.
It is named stack as it behaves like a real-world stack, for example – a deck of cards or a
pile of plates, etc.
A real-world stack allows operations at one end only. For example, we can place or
remove a card or plate from the top of the stack only. Likewise, Stack ADT allows all data
operations at one end only. At any given time, we can only access the top element of a
stack.
This feature makes it LIFO data structure. LIFO stands for Last-in-first-out. Here, the
element which is placed (inserted or added) last, is accessed first. In stack terminology,
insertion operation is called PUSH operation and removal operation is called POP
operation.

2.3 QUEUES
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue
is open at both its ends. One end is always used to insert data (enqueue) and the other
is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e.,
the data item stored first will be accessed first.
A real-world example of queue can be a single-lane one-way road, where the vehicle
enters first, exits first. More real-world examples can be seen as queues at the ticket
windows and bus-stops.

2.4 LINKED LIST


Linked List is a sequence of links which contains items. Each link contains a connection to
another link. Linked list is the second most-used data structure after array. Following are
the important terms to understand the concept of Linked List.

Page IX
Link − Each link of a linked list can store a data called an element.
Next − Each link of a linked list contains a link to the next link called Next.
LinkedList − A Linked List contains the connection link to the first link called First.

Linked List Representation


Linked list can be visualized as a chain of nodes, where every node points to the next
node.
As per the above illustration, following are the important points to be considered.
Linked List contains a link element called first.
Each link carries a data field(s) and a link field called next.
Each link is linked with its next link using its next link.
Last link carries a link as null to mark the end of the list.

Types of Linked List


Following are the various types of linked list.
Simple Linked List − Item navigation is forward only.
Doubly Linked List − Items can be navigated forward and backward.
Circular Linked List − Last item contains link of the first element as next and the first
element has a link to the last element as previous.

Basic Operations
Following are the basic operations supported by a list.
Insertion − Adds an element at the beginning of the list.
Deletion − Deletes an element at the beginning of the list.
Display − Displays the complete list.
Search − Searches an element using the given key.
Delete − Deletes an element using the given key.

2.4 TREES
Tree represents the nodes connected by edges. We will discuss binary tree or binary
search tree specifically.
Binary Tree is a special datastructure used for data storage purposes. A binary tree has a
special condition that each node can have a maximum of two children. A binary tree has
the benefits of both an ordered array and a linked list as search is as quick as in a sorted
array and insertion or deletion operation are as fast as in linked list. Following are the
important terms with respect to tree :
• Path − Path refers to the sequence of nodes along the edges of a tree.
• Root − The node at the top of the tree is called root. There is only one root per
tree and one path from the root node to any node.

Page X
• Parent − Any node except the root node has one edge upward to a node called
parent.
• Child − The node below a given node connected by its edge downward is called
its child node.
• Leaf − The node which does not have any child node is called the leaf node.
• Subtree − Subtree represents the descendants of a node.
• Visiting − Visiting refers to checking the value of a node when control is on the
node.
• Traversing − Traversing means passing through nodes in a specific order.
• Levels − Level of a node represents the generation of a node. If the root node is
at level 0, then its next child node is at level 1, its grandchild is at level 2, and so
on.
• Keys − Key represents a value of a node based on which a search operation is to
be carried out for a node.

2.5 GRAPHS
Mathematical graphs can be represented in data structure. We can represent a graph
using an array of vertices and a two-dimensional array of edges. Before we proceed
further, let's familiarize ourselves with some important terms −
• Vertex − Each node of the graph is represented as a vertex.
• Edge − Edge represents a path between two vertices or a line between two
vertices.
• Adjacency − Two node or vertices are adjacent if they are connected to each
other through an edge.
• Path − Path represents a sequence of edges between the two vertices.

2.6 FILES
A file is a container in computer storage devices used for storing data.
Why files are needed?
When a program is terminated, the entire data is lost. Storing in a file will preserve your
data even if the program terminates.If you have to enter a large number of data, it will
take a lot of time to enter them all.However, if you have a file containing all the data,
you can easily access the contents of the file using a few commands in C.You can easily
move your data from one computer to another without any changes.
Types of Files
When dealing with files, there are two types of files you should know about:
• Text files
• Binary files

Page XI
1. Text files
Text files are the normal .txt files. You can easily create text files using any simple text
editors such as Notepad. When you open those files, you'll see all the contents within
the file as plain text. You can easily edit or delete the contents. They take minimum
effort to maintain, are easily readable, and provide the least security and takes bigger
storage space.

2. Binary files
Binary files are mostly the .bin files in your computer. Instead of storing data in plain
text, they store it in the binary form (0's and 1's). They can hold a higher amount of data,
are not readable easily, and provides better security than text files.

File Operations
In C, you can perform four major operations on files, either text or binary:
• Creating a new file
• Opening an existing file
• Closing a file
• Reading from and writing information to a file

Working with files


When working with files, you need to declare a pointer of type file. This declaration is
needed for communication between the file and the program.
Syntax : FILE *fptr;

Page XII
3.DESIGN
3.1 FLOWCHART

Page XIII
3.2 PARTIAL CODE
3.2.1//Structure design for employee details
struct emp_data
{
int empno;
char empName[MAX];
char designation[MAX];
int sat;
float total;
float loan;
struct emp_data *next;
};

3.2.2//Insertion of details
struct emp_data *insert(struct emp_data *front, int id, char name[],
char desg[])
{
struct emp_data *newnode;
newnode = (struct emp_data*)malloc(sizeof(struct emp_data));
if (newnode == NULL)
{
printf("\n Allocation failed \n");
exit(2);
}
newnode->empno = id;
strcpy(newnode->empName, name);
strcpy(newnode->designation, desg);
newnode->sat = st;
newnode->total = (totalm-lo);
newnode->loan = lo;
newnode->next = front;
front = newnode;
return(front);
}

3.2.3//Deletion of employee details


struct emp_data* deleteNode(struct emp_data *front, int id)
{
struct emp_data *ptr;
struct emp_data *bptr;
if (front->empno == id)
{
ptr = front;
printf("\n Node deleted:");
printNode(front);
front = front->next;
free(ptr);

Page XIV
return(front);
}
for (ptr = front->next, bptr = front; ptr != NULL; ptr = ptr->next,bptr = bptr->next)
{
if (ptr->empno == id)
{
printf("\n Node deleted:");
printNode(ptr);
bptr->next = ptr->next;
free(ptr);
return(front);
}
}
printf("\n Employee Number %d not found ", id);
return(front);
}

3.2.4//Search a employee detail


void search(struct emp_data *front, int key)
{
struct emp_data *ptr;

for (ptr = front; ptr != NULL; ptr = ptr -> next)


{
if (ptr->empno == key)
{
printf("\n Key found:");
printNode(ptr);
return;
}
}
printf("\n Employee Number %d not found ", key);
}

3.2.5//Salary and loan Calculation


float salary()
{
float hr,sig,tot;
if(st == 1)
{
printf("\nEnter the cost per hour : ");
scanf("%f",&sig);
printf("\nEnter the total no. o hours : ");
scanf("%f",&hr);
tot = sig*hr;
}
else if(st == 2)

Page XV
{
printf("\nEnter the fixed salary : ");
scanf("%f",&tot);
}
else
printf("\nWrong salary type chosen");
return tot;
}

float loan()
{
if(lo != 0.0)
{
totalm = totalm - lo;
}
return totalm;
}

3.2.6//Display the details


void display(struct emp_data *front)
{
struct emp_data *ptr;

for (ptr = front; ptr != NULL; ptr = ptr->next)


{
printNode(ptr);
}
}
void printNode(struct emp_data *p)
{
printf("\n Employee Details...\n");
printf("\n Emp No : %d", p->empno);
printf("\n Name : %s", p->empName);
printf("\n Designation : %s\n", p->designation);
printf("\nLoan : %f",p->loan);
printf("\nTotal Salary :%f",p->total);
printf("\n-------------------------------------\n");
}

Page XVI
4.IMPLIMENTATION
4.1 Module 1
It is a structure for inputs of the employee which includes employee id, employee name,
type of salary he/she is provided by the organization, salary, loan if taken(any).

4.2 Module 2
The module is used to make entry of employees which comes to make organization. The
module accepts details, validates it and stored the details. The module is used to query
the employee in various ways, such as employee id, name, designation. The module
accepts the search criteria and according to gives criteria the module searches the detail
and display.

4.3 Module 3
The module allows us to remove an employee record according to the information given
by the user.

4.4 Module 4
The module accepts the search criteria and according to gives criteria the module
searches the detail and display.

4.5 Module 5
This module is used to calculate & pay salary of employee for each month. Before
calculating salary the module checks for loan of the employee of that month and
separates the salary. The module can also be used to pay fund to the employee. And
make enquiry of fund, salary and paid employee for a month.

4.6 Module 6
It displays the record of all the employees with all the details .i.e. employee id, employee
name, employee designation, employee salary.

Page XVII
5. RESULT
In the output screen there are five output i.e. employee id, employee name, employee
designation, salary, loan. Basically a node is created in a linked list for each employee
and according to inputs given by the user.

6.CONCLUSION
In this way this software will play a vital role for the salary calculation which was a mess
but with these initiatives this process will be simplified.

7.REFRENCES
• Tutorials point
• Study point

Page XVIII

You might also like