CT018 3 1itcp
CT018 3 1itcp
LBEF - NEPAL
CT018-3-1-ITCP
INTRODUCTION TO C PROGRAMMING
NP1F1801IT
INSTRUCTIONS TO CANDIDATES:
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).
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
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=5 T
Exit
7
Flowchart for different user:
Start
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
F
Case=2 T Register new
lecturer profile
F
T
FView leave status
Case=4
of lecturer
F
Upload leave
T
Case=6 policies
F
Invalid option/Exit
9
AL
T
Case=2 Approve/Reject/Delete the Leave
EExit
10
L
Declare Case
T
Case=1 Apply leave Application
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.
<stdio.h> is used to use standard I/O function printf and scanf. #include<stdlib.h>
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];
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];
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');
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:
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.
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.
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.
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.
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.
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.
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.
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