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

CT018 3 1itcp

The document describes an individual assignment to design an employee leave management system in C programming. It includes instructions for candidates, an introduction describing the purpose and users of the system, and sections on the design of the program using pseudocode and flowcharts. Sample C code is provided to explain concepts like header files, functions, data types, variables, file handling, loops, and decision making. The assignment requires candidates to submit a written report and source code that implements the design and demonstrates the system's functionality through sample outputs.

Uploaded by

raghav raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views

CT018 3 1itcp

The document describes an individual assignment to design an employee leave management system in C programming. It includes instructions for candidates, an introduction describing the purpose and users of the system, and sections on the design of the program using pseudocode and flowcharts. Sample C code is provided to explain concepts like header files, functions, data types, variables, file handling, loops, and decision making. The assignment requires candidates to submit a written report and source code that implements the design and demonstrates the system's functionality through sample outputs.

Uploaded by

raghav raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

INDIVIDUAL ASSIGNMENT

LBEF - NEPAL

CT018-3-1-ITCP

INTRODUCTION TO C PROGRAMMING

NP1F1801IT

HAND OUT DATE: 16 February 2018


HAND IN DATE: 27 May 2018
WEIGHTAGE: 100%

INSTRUCTIONS TO CANDIDATES:

1. Submit your assignment at the administrative center.


2. Students are advised to underpin their answers with the use of References (Cited
using the Harvard Name system of Referencing).
3. Last submission will be awarded zero (0) unless Extenuating Circumstances
(EC) is upheld.
4. Cases of plagiarism will be penalized.
5. The assignment should be bound in an appropriate style (comb bound or
stapled).
6. Where the assignment should be submitted in both hard copy and softcopy, the
softcopy of the written assignment and source code (where appropriate) should
be on a CD in an envelope / CD cover and attached to the hardcopy.
7. You must obtain 50% overall to pass this module.
Table of Contents
1. Introduction & Assumptions ............................................................................................... 1
2. Design of the program ......................................................................................................... 3
2.1 Pseudocode ..................................................................................................................... 3
2.2 Flowchart ........................................................................................................................ 5
3. Explanation of C Programming Concept ....................................................................... 9
3.1 Sample source codes .................................................................................................... 13
3.1.1 Header files................................................................................................................ 13
3.1.2 Functions ................................................................................................................... 14
3.1.3 Data Types ................................................................................................................. 15
3.1.4 Variables .................................................................................................................... 15
3.1.5 File Handling ............................................................................................................. 16
3.1.6 Loops ......................................................................................................................... 16
3.1.7 Decision Making ....................................................................................................... 17
4. Additional Features ............................................................................................................ 18
5. Sample output ..................................................................................................................... 18
6. Conclusion: ......................................................................................................................... 27
References
Table of figures:
Figure 1: Sample output 1...................................................................................................... 18
Figure 2: Sample Output 2 ..................................................................................................... 19
Figure 3: Sample Output 3 ..................................................................................................... 19
Figure 4: Sample Output 4 ..................................................................................................... 20
Figure 5: Sample Output 5 ..................................................................................................... 20
Figure 6: Sample Output 6 ..................................................................................................... 21
Figure 7: Sample Output 7 ..................................................................................................... 21
Figure 8: Sample output 8...................................................................................................... 21
Figure 9: Sample output 9...................................................................................................... 22
Figure 10: Sample output 10 ................................................................................................. 22
Figure 11: Sample output 11 ................................................................................................. 23
Figure 12: Sample output 12 ................................................................................................. 23
Figure 13: Sample output 13 ................................................................................................. 24
Figure 14: Sample output 14 ................................................................................................. 24
Figure 15: Sample output 15 ................................................................................................. 25
Figure 16: Sample output 16 ................................................................................................. 25
Figure 17: Sample output 17 ................................................................................................. 26
Figure 18: Sample output 18 ................................................................................................. 26
Figure 19: sample output 19 .................................................................................................. 26
1. Introduction & Assumptions
This assignment encloses the design and development of Employment Leave Management
system, which will be used for education section organization. The main purpose of this
system is to simulate employees leave management for an organization to maintain the
employee leave record, attendance record and to help employee for their planning about
the leave system. Principally there are three users for this system wherever they are:
 Human Resources (HR)
 Academic Leader (AL) and
 Lecture (L)
Here Human Resources (HR) is the chief user of this system wherever it can operate all the
function of the other user. The Employment Leave Management System contains different
roles of the user. They are as follow:-
 Human Resources(HR)
o Human Resources (HR) can provide different user id to the Academic
Leader and Lecture.
o Can create new Lecture/ Academic Leader and provide them login id and
password to access the system.
o Can modify, delete, view and search lecture profile accordingly.
o Can views the employee leave status.
o Can uploads the yearly leaves in the system.
o Can uploads and updates public and university holidays.
o Can updates and uploads FAQ about university leave policies in the system.
 Academic Leader
o Can view lecture leave application?
o Can approve the leave.
o Can delete the leave application.
o Can view all the public and university holiday.
 Lecturer
o Can apply leave application.
o Can update the leave.
o Can view all the public and university holiday.
1
The system is completed for the utilization of worker leave management to create them
simple to depart. Worker leave management is basic HR task and one that affects all
workers. Most firms have well-defined leave policies that area unit sent them to workers
and managers through worker handbooks or HR policy manuals. Nonetheless, HR is
hyperactive with body management of leave, change of leave balances and responding to
queries on balances and entitlements from workers and their managers. Workers too search
out it an irritation to own to fill in paper forms and chase them up with approving managers.
A major quantity of high-priced worker, manager and HR time is wasted in a very basic
HR method. HR issues of group action attending inputs from very different attending work
systems, card and biometric scanners and manual attending registers across all business
locations. Every month heaps of HR time is spent assembling and adaptive attending
knowledge before employees are often properly processed.
In this System, it stocks the information about the Academic Leader, Lecture and other
employ leave status. This one is used and control by the HR admin. The assignment
employee leaves management system manages employee records using a file system. This
help to register the employee, display all list of the employee in a screen, search a particular
employee record, modify and delete information of an employee.

2
2. Design of the program
2.1 Pseudocode
It is an easy method of programming description, which does not require any strict
programming language syntax. Pseudocode used for generating a sketch or a rough flow
of a program. Pseudocode recaps a program’s flow but omits core details. System creators
mark pseudocode to ensure that programmers understand a software project's necessities
and align code accordingly (Time, 2018).Pseudocode is not a real programming language.
Thus, it could not be compiled into an executable program. It uses small terms or simple
English language word order to write code for programs before which is literally converted
into a specific programming language. This is done to find top level flow errors and know
the programming data movements that the ending program is going to use. The purpose of
using pseudocode is an effectual key source of an algorithm. It is use in development an
algorithm with drawing out the structure of the program before the concluding coding takes
place (Time, 2018).

The pseudocode for ELMS are:

 START
 Declare Header File
 Display home menu.
 Run switch case for choosing login for HR, Academic leader or Lecturer.
 Case 1:
 Register HR username and password.
 Use string compare function to check username and password.
 If wrong Display wrong username or password.
 Else Display successfully login.
 Use switch case to choose different functions of HR.
 Case 1:
 Register Academic leader profile.
 Case 2:
 Register lecturer profile.
 Case 3:

3
 Display employee management system
 Use switch case to choose different functions in employee
management.
 Case 1:
o Register new employee.
o Use of do while loop if user wants to register again or exit.
 Case 2:
o View all employee recorded till date.
 Case 3:
o Ask username of the employee you want to modify.
 Case 4:
o Ask username of the employee you want to delete.
 Case 5:
o Exit the system.
 Case 4:
 Upload and Update public and university leave policies.
 Case 2:
 In Academic Leader function
 If user id and password=” provided by HR==True”
 Then logged into Academic Leader profile.
 Else display wrong username or password.
 Use switch case to run different functions of Academic Leader.
 Case 1:
 Check lecturers leave application.
 Case 2:
 Run switch case to approve, reject or delete leave.
 Case 1:
o Approve the leave.
 Case 2:
o Reject the leave.
 Case 3:

4
o Delete the leave.
 Case 3:
 View leave policies and FAQs.
 Case 3:
 In lecturer’s function.
 If user id and password =” Provided by HR == True”
 Then logged into Lecturers function.
 Else display wrong username or password.
 Use switch case to run different functions of Lecturer.
 Case 1:
 Apply the leave with start date, end date and leave type.
 Case 2:
 View leave status.
 Case 3:
 View leave policies and FAQs.
 Case 4:
 Exit the program.
 END

2.2 Flowchart
A flow chart may be an image of the separate steps of a method in consecutive order that
represents associate degree formula, workflow or method, showing the steps as boxes of
assorted types, and their order by connecting them with arrows (Paradigm, 2018).
A flowchart is a graphical representation /diagrammatical representation of the program
logic, uses a series of geometrical symbols and lines, which are connected according to the
logic algorithm. Describes what operation (and in what sequence) are required to solve a
given program. It is used to analyzing, designing, documenting or managing a process a
program in various fields.
This flowchart shows the proper function on leave taken by the employees of our university
staff with approval of academic leader and then updated by HR departments.

5
Start

Declare Case

Display Enter the Case

Home Menu

1. Add
2. View
3. Modify
4. Delete
5. Exit

Read Case

T
Case=1 Add user Add

T
CCase=2 View user View

1
6
1

T
Case=3 Modify user mModify

Case=4 T Delete user Delete

Case=5 T
Exit

Fig: Flowchart for user

7
Flowchart for different user:
Start

Display Enter the username, password

Read username, Password

Username: jibachh
If n=1? T HR Roles HR
Password: jibachh

T Academic AL
If n=2?
Leader Roles

T Lecturer LL
If n=3?
Roles

T
If n=4? Stop

8
HR

Declare Menu Case

Display Enter the Menu Case

Read the Case

Case =1 T Register new


academic profile

F
Case=2 T Register new
lecturer profile
F

Modify, delete, view


Case=3
T and search for lecturer

T
FView leave status
Case=4
of lecturer

T Upload leave in the


Case=5
system

F
Upload leave
T
Case=6 policies
F

Invalid option/Exit

9
AL

Declare Menu Case

Display Enter the Menu Case

Read the Menu Case

T Check Lecturer Leave


Case=1
Application

T
Case=2 Approve/Reject/Delete the Leave

T View all Holidays and Leave


Case=3
Policies

EExit

10
L

Declare Case

Display Enter Case

Read the Case

T
Case=1 Apply leave Application

Case=2 T Check Status of Leave


Application
F

Case=3Cas T View Leave Policy


e=3
F

Exit

11
3. Explanation of C Programming Concept
A programming language is a subset of the arrangement of common language. It contains
all the symbols, characters, and use decides that allow an individual to communicate with
the system. An assortment of programming language has been created throughout the long
periods of computer history. Among the different programming language, C is one, which
has its origin in the mid-1970s in Basic Combined Programming Language (BPCL).
Dennis Ritchie credited with characterizing and making C from the language B., numerous
others additionally influenced the advancement of the language (Kashi Nath Dey, 2010, p.
11).
C is a general-purpose, structured programming language. Its instructions consist of terms
that resemble algebraic expressions, argument by certain English keywords such as if, else,
for, do and while. In this respect, c resembles another high-level structured programming
language such as Pascal and FORTRAN. (Chhabra, 2011, p. 1.17).
C is powerful and flexible general-purpose language that has gained the widest of
acceptance over the years. Several features make a c very attractive programming language
for coding solutions. These include:
o Performance features such as speed and efficiency of the excitable program.
o Features relating to the portability of the program. C is the independent of any
particular machine architecture – it is bound to any hardware or system. A program
can be written to excite, without change, on a wide range of hardware.
o C is simple and straightforward language, providing only low-level operations and
none to deal directly with composite objects or other higher-level mechanisms.
o Its versatility enables it to be used to solve problems in every applications area.
o Modularity allows C to be ideal for large projects involving several programmers.
It lets us break a large program into small manageable pieces, which can be reused
in other programs.
Of course, the extent to which a particular program takes advantage of modularity and
portability depends on how well the program is written.
C is both low-and high-level language. It supports the low-level features needed by the
operating-system implementers and compiler writer. It also supports the high- level
features of control and data structures characteristics of procedural language. C is flexible

12
as a low-level language. On the other hand, C provides the tools for the structured program,
as a high-level language does. Thus, C is often called a middle-level programming
language. (Kashi Nath Dey, 2010, pp. 11,12)
It has a variety of uses after C is standardized with modern evolution of programming
language. The main use is to develop system applications that form a major portion of an
operating system like Windows, Linux, and UNIX. There are other basic uses of C; some
of them are listed below:
o Graphics packages
o Spreadsheets
o Network drivers
o Interpreters.

3.1 Sample source codes


In computing, source code is some group of code, perhaps with comments, written by
means of a human-readable programming language, generally as plain text. The source
code of program are especially designed to facilitate the work of computer programmers.
C programming is a structured language; it takes its own source codes and structure. The
illustration of sources codes from my made system, which is scheduled and defined below-

3.1.1 Header files


Header files is a heading with extension lead .h that contains C function declarations and
macro definitions to be shared between several source files (Tutorial point, 2018).
Note: Header files generally contain definitions of data types, function prototypes and C
preprocessor commands. (Sandeep jain, 2018)
#include<conio.h>
 #include shapes preprocessor to read in a text file.
 <conio.h> is used to create console screen. #include<stdio.h>

 <stdio.h> is used to use standard I/O function printf and scanf. #include<stdlib.h>

 <stdlib.h > is used to define various functions and variables. #include<windows.h>


 <window.h>is used for windows related function. #include<strings.h>
 <string.h> is used to manipulate arrays of Characters.

13
3.1.2 Functions
A function is a self-contained block or sub-program of one or more statements that
performs a special task when called.
The C language supports two types of function 1) Library functions 2) User defined
functions. The library functions are pre-defined sets of functions. Their task is limited. A
user cannot understand the internal working of these functions. The user-defined defined
function is totally different. The functions defined by the user according to his/her
requirement are called user-defined functions (N.KAMTHANE, 2009, pp. 310,311). The
source code of functions are:
 Leave_rejected() is user-defined function declared to store other various functions.
 Void main is system defined function, which is called by the operating system when
users run the program. It is called the main function of C programming because it
runs the whole program.
leave_rejectect()
{
FILE *rej;
rej=fopen("application.txt","w");
Void main() struct login c;
printf("Please enter (REJECT))");
scanf("%s",c.leave_reject);
fwrite(&c,sizeof(c),1,rej);
fclose(rej);
}

14
3.1.3 Data Types
C supports numerous types of data, for each of which may be signified in a different way
inside the computer’s memory. There are different data types: int, float, double, and char
are the basic data types. Source code of data type used in the system(ELMS):

Int a;

Char
Userid[20];

 Int is an integer quantity that helps to store all numeric value.


 Char is a single character that helps to store characters.
 [20] Means number of character that userid variable can store.
 A float is a floating-point number (i.e., a number containing a decimal point and/or
an exponent) that helps to hold a real number.
 Double is a double-precision floating-pointer number (i.e., more significant figures,
and an exponent, which may be larger in magnitude) (Kashi Nath Dey, 2010, p.
2.11).

3.1.4 Variables
A variable is an entity whose value can vary during the execution of a program. The value
of a variable can be changed because it has a modifiable l-value. Since it has a modification
l-value, it can be placed on the left side of the assignment operator. Different data types are
used to store different data in variables (Mittal, 2010, p. 10) Source codes of variables used
in the system (ELMS):
int k;

Char address[20];

o K is a variable, used to switch various function where values are stored.

o Address[20] is a variable, used to store the string or character type value.

15
3.1.5 File Handling
A file represents a sequence of bytes on the disk where a group of related data is stored. A
file is created for permanent storage of data (Abhijit singh, 2018). It is a ready-made
structure. There are two types of file text file and binary files. A text file contains the codes
of digits, alphabets, and symbols whereas binary files contain a collection of bytes (0's and
1's). Opening, writing, closing and reading a file are the basic operations of file handling.
Source codes of file handling:

FILE *la;
la=fopen("leave.txt","r");
struct login a;
fread(&a,sizeof(a),1,la);
printf("%s\tStart
Date\n%s\tEnd
Date\n%s\t\tLeave
Type\n",a.sdate,a.edate,a.ltype)
;

fclose(la);

o la is file pointer which opens file named “leave.txt” in read mode. The file will be
opened in text format.
o fread is a keyword to read what is written inside the text file (i.e. leave.txt).
o fclose(la) closes the file returning to finish mode.

3.1.6 Loops
Loops are used in programming to repeat a specific block until some end condition is met.
There are three loops in C programming (Learn C, 2018):
i. for loop
ii. while loop
iii. Do...while loop.
I have cast-off loop to store data in files in my created system. Source code of loops in
ELMS:

16
while (1) {
if (i < 0) {
i = 0;
}
ch = getch();

if (ch == 13)
break;
if (ch == 8) /*ASCII value of
BACKSPACE*/
{
putch('b');

3.1.7 Decision Making


C decision statements permit you to sort a decision, established upon the outcome of a
situation. These statements are called as also called Conditional Statements (Gosh, 2018).
Here are some sorts of Decision making statements, they are: if, if else, nested if and switch
case. Switch case can be also called decision-making statements. Source code for ELMS
is:

switch(k)
{case 1:reg1();break;
case 2:reg2();break;
case 3: lect(); break;
case 4:levstat();break;
default:
printf("Please enter a valid
option\n");}

o Switch switches the variable k and if the users entered 1 it opens statement 1 and if
the users entered 2 it opens statements 2.
o Else it will go to the default statement.

17
4. Additional Features
The system is generated presence based on the criteria's mentioned in the assignment. Some
features that I have added on this assignment is that I have used background color function
to make it look little bit better and the while loop to hide user password. The username that
I have used in my program is jibachh and password is jibachh.

5. Sample output
Output of the program when runned are taken screenshot and shown below:

Figure 1: Sample output 1


The above figure shows the main menue. Here, we can see four options we can access
from. Here, I pressed 1 so it opens the hr login system.

18
Figure 2: Sample Output 2
As soon as I open HR login system. It asks us to press username and password. After
pressing username and password HR system opens up and then we are given six options to
choose from. As I press 1 it opens up the registration form for Academic Leader.

Figure 3: Sample Output 3


In the sample output 3 we can register the new academic leader profile. As I am registering
first name, last name, username and password for academic leader.

19
Figure 4: Sample Output 4
Now when I press 2 and open the registration page for lecturer. Similarly, of academic
leader HR can register the profile for new lecturer and give username and password.

Figure 5: Sample Output 5


From HR menu when I press 3 then employee record management system opens up.
Where we can add, view, modify and delete employee record.

20
Figure 6: Sample Output 6
From the employee record management page if we click 1 then we can add new employee to our
organization as I have done in sample output 6.

Figure 7: Sample Output 7


In the sample output 7 I have shown the list of employees in our organization, which is added by
HR like shown in Sample Output 6. To view the employee record I pressed option 2 from
employee record management page.

Figure 8: Sample output 8

21
From the record management page when I press 3which is to modify the employee that currently
we have. Here, to modify the employee we have to give the name of employee we want to
modify. Now we can modify the employee name, address, age, and basic salary.

Figure 9: Sample output 9


When we click 4-form employee leave management page we can delete the employee as
they leave the organization. Which does HR do by simply typing the name of the employee.

Figure 10: Sample output 10


As we can see when we login the HR page we are given 6 functions that HR can do.
Among them if we press 6 we can upload the policy for the employee leave policy and
view them. Sample of policy is shown in Sample Output 10.

22
Figure 11: Sample output 11
Here, in sample output 11 we open up the lecturer login page by pressing 3 from the
menu page. As HR had previously registered the username and password for lecturer.
Now when the lecturer keeps the username and password given by HR he can apply leave
application and check the status of leave application.

Figure 12: Sample output 12


When lecturer presses 1 and applies for the leave he has to give details about the starting
date ending date and choose leave type from medical casual and emergency leave.
23
Figure 13: Sample output 13
Now after lecturer applies the leave, it is in academic leaders hand to approve or reject
the leave application. Now, in sample output 3 academic leader opens up the login by
keeping username and password given by HR. Now academic leader can view the leave
application and accept or reject the application. When he presses 1 he can view the leave
application applied by the lecturer.

Figure 14: Sample output 14


In sample output 14 when academic leader checks the leave application then he can
accept or reject the application by pressing 2 as done above. When entering the option 2
then he is asked to type reject. After he types reject the academic leader rejects the
application.

24
Figure 15: Sample output 15
After academic leader rejects the application, the lecturer can view the leave status by
clicking 2 in lecturer page as done in output 15. Here he sees that his application has been
rejected.

Figure 16: Sample output 16


In addition, the HR can view the leave status of his employee but he cannot do anything.
When we press 4 which is for viewing the leave status of lecturer. He sees that the academic
leader has rejected the application.

25
Figure 17: Sample output 17
Now there is an option for leave calendar to upload public holiday and university holiday
in the system. First HR must logged in their system and if he/she press option 5 then the
below output is appears.

Figure 18: Sample output 18


There are numerous structures in this system now I’m going to finalize the sample output
with the main menu and the exit system is given below:

Figure 19: sample output 19

26
6. Conclusion:
The proposed Leave Management System will influence the entire leave administration to
process proficient. An Employee will have the capacity to know their leave status. The
lecturer possibly applying for leave from ELMS software also. This supporting
programming will help the administration in basic leadership if there should be an
occurrence of leave related issues. Additionally, it will guarantee less paper works and
subsequently the entire procedure will be quick and dependable.

It was extraordinary experience to outline and actualize the Employee Management System
by utilizing C programming language and to deal with its documentation. While chipping
away at this undertaking it helped me to show signs of improvement comprehension of
fundamental programming ideas of C programming language, for example, loop, control
structure, arrays, file handling and so on in this task I have utilized relatively every ideas
of C programming language, I had learned. I have likewise utilized brilliant rationale
related remarks with legitimate space.

27
References
Abhijit singh, A. D. K. S., 2018. Study tonight. [Online]
Available at: https://www.studytonight.com/c/file-input-output.php
[Accessed 08 06 2018].
Chhabra, J. K., 2011. Programming with C. New Delhi: Mc Graw Hill.
Gosh, G., 2018. W3Schools. [Online]
Available at: https://www.w3schools.in/c-tutorial/decision-making/
[Accessed 08 06 2018].
Kashi Nath Dey, S. B., 2010. C Programming Essentials. New Delhi 110017, India:
Dorling Kindersely (India) Pvt. Ltd, Licencees of Pearson Education in South Asia.
Learn C, 2018. LEARN C. [Online]
Available at: https://www.programiz.com/c-programming/c-for-loop
Mittal, A., 2010. Programming in C. Noida: Dorling Kindersley.
N.KAMTHANE, A., 2009. C and Data Structures. First Impression,2009 ed. New Delhi
110017(New Delhi): Dorling Kindersley(India) Pvt. Ltd, Licenssees of Pearson
Education in South Asia.
Paradigm, V., 2018. Visual Paradigm. [Online]
Available at: https://online.visual-paradigm.com/tutorials/flowchart-tutorial/
[Accessed 06 05 2018].
Sandeep jain, H. G. V. B. g., 2018. Geeks for Geeks. [Online]
Available at: https://www.geeksforgeeks.org/write-header-file-c/
[Accessed 08 06 2018].
Time, T. E., 2018. The Economics Time. [Online]
Available at: https://economictimes.indiatimes.com/definition/pseudocode
[Accessed 05 May 2018].
Tutorial point, 2018. C_header file. [Online]
Available at: https://www.tutorialspoint.com/cprogramming/c_header_files.htm
[Accessed 08 05 2018].

28

You might also like