0% found this document useful (0 votes)
50 views

Krishna Gupta Himanshu Chavan: Suman Educational Trust's Dilkap Research Institute of Engineering and Management Studies

The document is a project report for an employee database created by Krishna Gupta and Himansh Chavan. It includes chapters on introduction, description, and implementation of the project. The project allows users to add, list, delete, and view employee records stored in a text file. The source code implements functions to open, read, write, and close the employee data file to manage employee records. Screenshots show sample outputs of adding an employee record and listing stored records.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Krishna Gupta Himanshu Chavan: Suman Educational Trust's Dilkap Research Institute of Engineering and Management Studies

The document is a project report for an employee database created by Krishna Gupta and Himansh Chavan. It includes chapters on introduction, description, and implementation of the project. The project allows users to add, list, delete, and view employee records stored in a text file. The source code implements functions to open, read, write, and close the employee data file to manage employee records. Screenshots show sample outputs of adding an employee record and listing stored records.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

DATA STRUCTURE LAB Report

Suman Educational Trust’s

Dilkap Research Institute of Engineering and Management Studies

A PROJECT REPORT ON

KRISHNA GUPTA
HIMANSHU CHAVAN

Second Year Engineering (Sem-III)

Department of Computer Engineering

Dilkap Research Institute of Engineering and Management Studies

Campus: Village Mamdapur, post- Neral, Tal: Karjat, Pin- 410101


University of Mumbai
2017-2018
2018-2019

Page | 1
DATA STRUCTURE LAB Report

Suman Educational Trust’s


Dilkap Research Institute of Engineering and Management Studies

Department of Computer Engineering

Academic year 2017-18

CERTIFICATE
THIS IS TO CERTIFY THAT

1.KRISHNA GUPTA(10)

2.HIMANSHU CHAVAN(07)

Have satisfactorily completed the requirements of the Data Structure Project


entitled
“EMPLOYEE DATABASE”

As prescribed by the University of Mumbai Under the guidance of


PROF.ARTI ORCHANI

Prof.Arti Orchani Prof.Ankush Pawar


(Project Guide) (H.O.D)

Page | 2
DATA STRUCTURE LAB Report

ACKNOWLEDGEMENT

We would like to express our gratitude and appreciation to all those who
gave us the possibility to complete this project and this report. I and my
team thank our head of department Prof. Ankush Pawar for giving us the
necsesorry environment to acquire knowledge and skill. A special thanks
to Ms. Arti Orchani Mam, whose help, stimulating suggestions and
encouragement, helped us to coordinate our project especially in writing
this report.

We would also like to acknowledge with much appreciation the crucial


role of the staff of Computer Laboratory, who gave the permission to use
all required machinery and the necessary material to complete the report
special thanks goes to our friends, who gave suggestions about the
source code.

Page | 3
DATA STRUCTURE LAB Report

CONTENTS

CHAPTER NO. TITLE PAGE NO.

Page | 4
DATA STRUCTURE LAB Report

CHAPTER 1
1.1 INTRODUCTION :

The objective of this assignment is to develop a C language


for an Employee Management System, where it is expected
to enter, search, edit and view personnel information of the
Employee in an Organization based on different access
priority and view salary package. The main purpose of
this mini project is to store and edit the complete personal
record of each Employee along with evaluation of salary
(annually) in an organization. And all information that is to
be added and edited must be handled via text (.txt) or data
(.dat) file, so that the information can be uploaded back
into the system once activated or saved when the system is
exited. We are also required to incorporate the Validation
throughout the project for each entry, from the user in
order to avoid data. We are supposed to describe, justify
and implement in these project.

Page | 5
DATA STRUCTURE LAB Report

CHAPTER 2

2.1 DESCRIPTION:
The project is create to collect data of employee, this
project contains certain function that needs to be
incorporated in the system design. So, for getting the
better understanding of the project, these modules are
described below –

The project is allowed to:


 Add Employee (name) as users of the system.
 List all employee data.
 Delete record of any Employee.
 Salary of particular employee.

Page | 6
DATA STRUCTURE LAB Report

CHAPTER 3

CHAPTER 3 .IMPLEMENTATION

File Handling in C So far the operations using C


program are done on a prompt / terminal which are
not stored anywhere. But in software industry, most
of the programs are written to store the information
fetched from the program. One such way is to store
the fetched information in a file.
Different operations that can be performed on a file
are:
1. Creation of a new file (fopen with attributes as “a”
or “a+” or “w” or “w++”)
2. Opening an existing file (fopen)
3. Reading from file (fscanf or fgetc)
4. Writing to a file (fprintf or fputs)
5. Moving to a specific location in a file (fseek,
rewind)
6. Closing a file (fclose)

Page | 7
DATA STRUCTURE LAB Report

Source Code:
#include <stdio.h> ///for input output functions like printf, scanf
#include <stdlib.h>
#include <string.h> ///string operations
void flush()
{
int c;
while ((c = getchar()) != '\n' && c != EOF);
}
int main(){
FILE *fp, *ft; /// file pointers
char another, choice;

/** structure that represent a employee */


struct emp{
char name[40]; ///name of employee
int age; /// age of employee
float bs; /// basic salary of employee
};
struct emp e; /// structure variable creation
char empname[40]; /// string to store name of the employee
long int recsize; /// size of each record of employee
/** open the file in binary read and write mode
* if the file EMP.DAT already exists then it open that file in read write mode
* if the file doesn't exit it simply create a new copy
*/
fp = fopen("EMP.DAT","rb+");
if(fp == NULL){
fp = fopen("EMP.DAT","wb+");
if(fp == NULL){
printf("Connot open file");
exit(1);
}
}
/// sizeo of each record i.e. size of structure variable e
recsize = sizeof(e);
/// infinite loop continues untile the break statement encounter
while(1){
printf("1. Add Record\n");
printf("2. List Records\n");
printf("3. Delete Records\n");
printf("4. Exit\n");
printf("Your Choice: ");
fflush(stdin); /// flush the input buffer
scanf("\n%c", &choice); /// get the input from keyboard

Page | 8
DATA STRUCTURE LAB Report
switch(choice){
case '1': /// if user press 1
fseek(fp,0,SEEK_END); /// search the file and move cursor to end of
the file
another = 'y';
while(another == 'y'){ /// if user want to add another record
flush();
printf("\nEnter name: ");
fgets(e.name, 40, stdin);
printf("\nEnter age: ");
scanf("%d", &e.age);
printf("\nEnter basic salary: ");
scanf("%f", &e.bs);

fwrite(&e,recsize,1,fp); /// write the record in the file

printf("\nAdd another record(y/n) ");


fflush(stdin);
scanf("\n%c", &another);
}
break;
case '2':
rewind(fp); ///this moves file cursor to start of the file
while(fread(&e,recsize,1,fp)==1){ /// read the file and fetchof thethe
record one record per fetch
printf("\n%s %d %.2f\n",e.name,e.age,e.bs); /// print the name,
age and basic salary
}
break;
case '3':
another = 'y';
while(another == 'y'){
flush();
printf("\nEnter name of employee to delete: ");
fgets(empname,40, stdin);
ft = fopen("Temp.dat","wb"); /// create a intermediate file for
temporary storage
rewind(fp); /// move record to starting of file
while(fread(&e,recsize,1,fp) == 1){ /// read all records from
file
if(strcmp(e.name,empname) != 0){ /// if the entered record
match
fwrite(&e,recsize,1,ft); /// move all records except the
one that is to be deleted to temp file
}
}
fclose(fp);
fclose(ft);
remove("EMP.DAT"); /// remove the orginal file
rename("Temp.dat","EMP.DAT"); /// rename the temp file to
original file name
fp = fopen("EMP.DAT", "rb+");
printf("Delete another record(y/n)");
fflush(stdin);
scanf("\n%c", &another);
}
break;

Page | 9
case '4':
fclose(fp); /// close the file
exit(0); /// exit from the program
}
}
return 0;
}

Page | 10
DATA STRUCTURE LAB Report

CHAPTER 4: SNAPSHOTS

ADDED EMPLOYEE DATA..


Page | 11
DATA STRUCTURE LAB Report

EMPLOYEE DATA WHICH I


ADDED IN LIST .. IS LISTED
WHEN WE ENTER CHOICE :2

Page | 12
EMPLOYEE DATA WHICH I ADDED IN
LIST .. IT CAN DELETED WHEN U
CHOICE OPTION 3…ENTER THE
EMPLOYEE NAME WHICH DATA YOU
WISH TO DELETE
Page | 13
DATA STRUCTURE LAB Report

CHAPTER 6: CONCLUSION

CHAPTER 6: CONCLUSION
It was a great experience to design and
implement the Employee Management
System by using an C language and to work
on its documentation. While working on this
project, I have learned many things especially
how to apply the concepts of file handling
structure. This assignment helped me to get
the better understanding to develop and
derive new class structures. It also helped me
in getting in the better understanding of basic
programming concepts of C language such as
loops, control structure, file handling etc.
After doing this assignment, I am in position
to explain Employee data structure mini
project.

Page | 14
CHAPTER 6: FLOWCHART

Page | 15
Page | 16
Page | 17
Page | 18
Page | 19

You might also like