0% found this document useful (0 votes)
165 views14 pages

Algorithms and Data Structure in C Documentation

The document provides instructions for an individual assignment on algorithms and data structures in C. Students are asked to create a program to store employee data using a linked list. The program must allow adding, searching, sorting, updating, and deleting employee records. Key elements of the program include using a struct to store employee information in a linked list, a menu to select options, and functions to implement required operations on the data. The output shows sample runs of calculating salary, adding records, searching, sorting, updating, and deleting an employee from the linked list.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
165 views14 pages

Algorithms and Data Structure in C Documentation

The document provides instructions for an individual assignment on algorithms and data structures in C. Students are asked to create a program to store employee data using a linked list. The program must allow adding, searching, sorting, updating, and deleting employee records. Key elements of the program include using a struct to store employee information in a linked list, a menu to select options, and functions to implement required operations on the data. The output shows sample runs of calculating salary, adding records, searching, sorting, updating, and deleting an employee from the linked list.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 14

INDIVIDUAL ASSIGNMENT

TECHNOLOGY PARK MALAYSIA

CE00869-4-ADSC

ALGORITHMS AND DATA STRUCTURES IN C

     

HAND OUT DATE: 24 APRIL 2020

HAND IN DATE: 12 JUNE 2020

WEIGHTAGE: 50%
INSTRUCTIONS TO CANDIDATES:

1 Students are advised to underpin their answers with the use of references
(cited using the Harvard Name System of Referencing).

2 Late submission will be awarded zero (0) unless Extenuating Circumstances


(EC) are upheld.

3 Cases of plagiarism will be penalised.

4 The assignment should be bound in an appropriate style (comb bound or


stapled).

5 Where the assignment should be submitted in both hardcopy 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.

  AVINASH DASHWIN BARGAVAN

  TP058302

Algorithms and Data Structure in C Documentation


Table of contents:

Introduction:
Data structure:
Algorithm:
Output:
Conclusion:
Reference:

Introduction:
EMERGE is a company that is currently developing rapidly, however the company require a
program to store some data regarding it’s employees such as employee number, name, salary,
phone number, ddress, department Number, department name and overall performance. The
company is currently using a filling system which contain several flaws such as when searching
for a specific record, it is not easily found as it might have been misplaced in a different
category or record is not placed in correct alphabetical sequence. It is challenging for the HR
staff as it is hard to get an employee file quickly. Additionally, when an employee leaves the
company, the record would be destroyed in six months. Therefore in this scenario, linked list
would be used in order to program

a) The system must require the following:


- Calculation of a salary package.
- Allow to add an employee record
-Display of the records
- Search by employee ID
- Search by employee overall performance
- Sort and display Employee ID in ascending order
-Sort and display Employee Salary in ascending order
- Sort and display Employee Overall Performance in ascending order
- Modify/ update an Employee Record
- Delete/ destroy an Employee Record
- Exit

Data Structure:
Linked list, if-else statements, variables are mostly used in this program.
The first step is to go to the preprocessor and type out _CRT_SECURE_NO_WARNINGS on
the preprocessor definitions. It is used to get rid of the warnings which would disrupt the code
from running.

In the picture above Employeedata is the struct/ linked list. Information regarding the employee’s
is stored inside the list.
List out the variables that’s going to be used in this program. The variables are used to store
different type of data across the program.

Now, use the switch statement. The statement is used to allow the value of a expression, variable
to change the flow of control according to the program execution. Based on the choice given
after the code has run, a list of option would be given to the user. Once the user has selected a
number, the search function then begin to operate to pull out the necessary details.

If -else statements are used as controls of the execution of the programs based off a true
condition. In this example from the delete function, the if-else statement will print “The list is
currently empty” if the variable element is empty; Else it will delete the employee’s information.
Algorithm:

In this program, linked list would be used. Linked list is a series of data structures that is
connected together through the links given/provided. Functions known as void would be stated at
the beginning of the code. It is known as void due to the fact that there isn’t a return value. After
that variables are needed in order to store data and execute it’s given function. There are
different type of variables. Examples of variables are such as char which is short for character,
int which is short for integers (only stores numbers) and float.
The first step is to state EmployeeData as it’s struct, this is the first structure of the code. It’s
going to store all the record of the employee’s such as employee’s ID number, name, salary,
phone number, address, department number, department name and the overall performance of
the employee. Then, nodes are then stated at the end of the structure to show pointer variables.
The “*” are the pointers, once stated as pointer variables, the variables become the nodes. The
function that is currently used is the do=while loop and the menu function. The do-while loop is
used to repeat the switch until variable is equal to nine. If it doesn’t equal to nine, there’s no
option found and it could not work. The menu function however would search for an input for
selection of options of integers between one to seven. The switch case will then execute it’s task
based on the selected option.
Another function would be known as the search function which would search employee’s based
on their overall performances or given ID. The two options given would run on the same type of
process/procedure which would scan the input and search for the overall performance or ID that
is alike. After the system has found an alike form of data from the list, it’ll then print out the data
found once the employee is found. If the employee isn’t in the system, it’ll print out “Employee
not recognized”.
The create function would add an employee by storing additional information inside the
variables in the struct known as EmployeeData. A function known as destroy in the program
would delete all the employee records by an ID scan and remove all information regarding the
employee once it’s found. Next, there’s an update function that allows the modification of data
through an ID scan. This would ask the users to add/change data, after that it would store the
updated data in the list. Then, there’s a function known as calculate that would sum up the basic
salary, transport allowances, medical allowances and other allowances after collecting the details
in which would be known as their salary package. It would be stored in variables before using
the calculate function based on the given formula in the program.
A function known as display would display information regarding the employee based on the ID
stated by the user.
Output:

The above picture shows the output of the main menu

1)The above picture shows the calculation of an employee’s salary.

2)The above picture shows the creation of employee record.


3)The above picture shows the display of an employee record.

4)The above picture shows the search for an employee through ID.

5)The above picture shows the search of an employee through overall performances.
6)The above picture shows the sort and display functions through either identification, salary or
overall performance of the employee

7)The above picture shows the update of an employee record either through name attribute,
address or phone number. For this case, address was chosen.

8)The above picture shows the option to remove an employee.


The eighth option is to exit.
Conclusion:
In this assignment, I’ve learnt to understand and program in C. A system was created through
this assignment. Various type of variables and other coding form has been taught in this as well.
The knowledge of programming in C could now be applied in creating different types of systems
as this assignment was completed. This programming language could now be applied in future
lifestyle/experience when it comes to doing certain task. With this completed program, I can now
understand C in a better way.
References:
1)Tutorialspoint.com. 2020. Linked List Program In C - Tutorialspoint. [online] Available at:
<https://www.tutorialspoint.com/data_structures_algorithms/linked_list_program_in_c.htm>
[Accessed 12 June 2020]
2)Study.com. 2020. [online] Available at: <https://study.com/academy/lesson/linked-lists-in-c-
programming-definition-example.html> [Accessed 12 June 2020].
3)Tutorialspoint.com. 2020. C - Variables - Tutorialspoint. [online] Available at: <
https://www.tutorialspoint.com/cprogramming/c_variables.htm#:~:text=A%20variable%20is%
20nothing%20but,be%20applied%20to%20the%20variable.> [Accessed 12 June 2020].
4)W3schools. 2020. C If-Else Statements. [online] Available at: <https://www.w3schools.in/c-
tutorial/decision-making/if-else/> [Accessed 12 June 2020].
5) fresh2refresh.com. 2020. C Code For Bank Application | Learn C Program | Fresh2refresh
.Com. [online] Available at: <https://fresh2refresh.com/c-programming/c-programs/c-code-for-
bank-application/> [Accessed 12 June 2020].
Marking Scheme


NAME : ID :

Marks
Criteria
Excellent Good Average Poor Very
Poor

1. Correctness of the program and (16-20) (11-15) (8-10) (5-7) (0-4)


accomplishment of the required
functions

2. Steps and explanation of the working of (8-10) (6-7) (4-5) (3) (0-2)
the algorithms

3. Presentation of the solutions obtained (8-10) (6-7) (4-5) (3) (0-2)

4. Discussion and Critical Appraisal (8-10) (6-7) (4-5) (3) (0-2)

L
Comments:

You might also like