50% found this document useful (2 votes)
559 views26 pages

Prog102 - Assignment 1 Tran Duc Phuong

The document describes an assignment front sheet for a procedural programming unit. It includes the student's name, ID number, class details, and a declaration that the submitted work is their own. The grading grid at the bottom will be used to assess the assignment.
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
50% found this document useful (2 votes)
559 views26 pages

Prog102 - Assignment 1 Tran Duc Phuong

The document describes an assignment front sheet for a procedural programming unit. It includes the student's name, ID number, class details, and a declaration that the submitted work is their own. The grading grid at the bottom will be used to assess the assignment.
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/ 26

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Prog102: Procedural Programming

Submission date 03/03/2022 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Tran Duc Phuong Student ID GBH200021

Class GCH1006 Assessor name Dinh Duc Manh

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.

Student’s signature Phuong

Grading grid

P1 P2 P3 M1 M2 D1

1
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:
Table of Contents
I. Introduction ................................................................................................................... 4
I.1. General concepts about procedural programming ............................................... 4
I.2. Characteristics of procedural programming ........................................................... 4
I.2.1. Characteristics ........................................................................................................ 5
I.2.2. Key feature ............................................................................................................. 5
I.3. Problem statement ..................................................................................................... 5
I.4. How Procedural Programming can be applied this problem .................................... 6
II. Analysis ....................................................................................................................... 7
II.1. List data types, data structures needed in problem ............................................... 7
II.1.1. Data type ............................................................................................................... 7
II.1.2. Data structure ........................................................................................................ 8
II.2. Statement needed in the program ........................................................................... 9
III. Design ........................................................................................................................ 12
III.1. WBS ........................................................................................................................ 12
III.2. Use case diagrams .................................................................................................. 14
III.3. Flowchart ............................................................................................................... 15
IV. Evaluation ................................................................................................................. 25
IV.1. General evaluation................................................................................................ 25
IV.2. Advantage and disadvantages of procedural programming ............................. 25
V. Conclusion ................................................................................................................ 26
Reference: ........................................................................................................................... 26

3
I. Introduction
I will discuss the principles of procedural programming as well as how to create use case diagrams and
flowcharts for the topic at hand in this report, which is a synthesis of both assignments. The software
will be designed to address the problem based on diagrams and graphs.

I.1. General concepts about procedural programming


Procedural Programming is likely to be a new developer's first programming paradigm. Procedural
code, in its most basic form, is the code that tells a device how to do a job in logical stages. This
paradigm takes a top-down, linear approach to data and methods, and sees them as two distinct things.
Procedural Programming separates a program into procedures, which are sometimes known as routines
or functions and simply comprise a set of actions to be carried out, based on the notion of a procedure
call. Procedural programming simply lays down a series of instructions that teach the computer how to
complete a task step by step.

Computer processes have traditionally been specified using procedural languages. That is, a computer
program is generally expressed as a sequence of steps. (Katz and McGee, 1963)

Figure 1: Procedural programming

I.2. Characteristics of procedural programming

4
I.2.1. Characteristics

• A top-down method is used in procedural programming.


• The program is organized into functions, which are blocks of code that each execute a specified
purpose.
• Real-world processes are modeled as 'procedures' that operate on 'data' in procedural systems.
• Data and functions are separate from one another.
• In software, data is free to move about.
• It's simple to follow a program's logic.
• By invoking another function, a function can have access to its data.

I.2.2. Key feature

• Predefined functions: A predefined function is a type of instruction that has a name attached to
it. Predefined functions are usually included in higher-level programming languages; however,
they are drawn from a library or registry rather than a program. 'charAt ()' is an example of a
pre-defined function that looks for a character located in a string.
• Local Variable: A local variable is a variable that is defined in the method's primary structure
and is only used inside the scope of the method. The local variable can only be used in the
method in which it is defined; if it is used outside of that function, the code will fail.
• A global variable is a variable that is declared outside of any other functions created in the
code. As a result, unlike local variables, global variables can be utilized in any function.
• Modularity occurs when two distinct systems have two separate jobs to complete, yet they are
joined together to complete a bigger task first. The tasks of each set of systems would
subsequently be completed one by one until all tasks were completed.
• Parameter Passing: A system for passing parameters to functions, subroutines, and procedures
is known as parameter passing. 'Pass by value', 'pass by reference', 'pass by result', 'pass by
value results’, and 'pass by the name' are all methods for passing parameters.

I.3. Problem statement


Problem: Teaching and human resource management are becoming increasingly challenging in today's
world, particularly in light of the current Covid 19 pandemic. It is also becoming increasingly difficult for
instructors to teach. When submitting assignments in hard copy, for example, it will take a long time for
teachers to move, print, examine, grade, and react to students as promptly as feasible. A math teacher is
responsible for overseeing course grades. He asks you to help him write a tiny application to do this. He
wants to keep track of student IDs, names, and grades, as well as who has the best and worse grades.

Solve: To meet the above requirements, we'll need to create a management program with basic functions
like importing and exporting personal information, looking up and editing information, calculating scores,
sorting orders, and so on. This problem will be solved quickly, simply, and effectively using algorithms
written in the C programming language.

5
I.4. How Procedural Programming can be applied this problem
A procedural programming language such as C or Pascal is usually the first programming language the
most students come across. However, in most curriculums, the concept of 'procedure is introduced to the
students after almost half of the course is covered. Many students are then found to be reluctant to get the
fruit of the procedural style of programming. (Abdullah-Al-Wadud, 2016)

A flowchart is a graphic means of documenting a sequence of operations. Flowcharts serve as a pictorial


means of communicating from one person to another the time-ordering of events or actions. As a pictorial
format, flowcharts have been the subject of both an International and an American National Standard
(ANSI, 1970; Chapin, 1979). Flowcharts go by many other names, including block diagrams, flow
diagrams, system charts, run diagrams, process charts, logic charts, and iteration diagrams. (Chapin, 2003)

Figure 2: Example of flowchart

We may then identify each step required to get the desired outcome and create flawless software that fits
the problem's criteria. Procedural programming splits a program into processes, often known as routines or
functions, based on this. They all work together to ensure that our programs are as clear and efficient as
possible. Furthermore, because C is a fundamental and widely used programming language, we can be
confident that it will run smoothly on all operating systems.

6
II. Analysis
II.1. List data types, data structures needed in the problem
II.1.1. Data type
In programming C as well as some other procedural programming, there are 4 main data types. The
data type is the part that defines the values a variable can take or the value a function can return. In
the C programming language, data types constitute the semantics and characteristics of the storage of
data elements. They are expressed in the language syntax in form of declarations for memory
locations or variables. Data types also determine the types of operations or methods of processing of
data elements.

• Integer:

Whole numbers with zero, positive, and negative values but no decimal values are known as
integers. We can use int for declaring an integer variable. For example:

Figure 3: Example of int

I used char to declare a variable that is a string of characters, such as a student's name, gender, etc.
In truth, char is a kind of number declaration, but it knows the ASCII letters A, B, C, and so on
depending on the value. For instance, letter A correlates to the number 65, letter H to the number
104, and so forth. Furthermore, unlike Java or other programming languages, C does not have a
String type definition, therefore I used char to define a string of those characters. Consider the
following scenario:

Figure 4: Example for char

• Float
This type returns an integer in decimal (floating point) format. With this type, I used to define
score variables, compute the total score, the average score, and so on, so that we could readily
view and compare them to see who was the best. Consider the following scenario:

7
Figure 5: Example for float

• Void
When void is used as a function return type in computer programming, it denotes that the
function does not return a value. When the keyword void appears in a pointer declaration, it
means the pointer is universal. When void is used in a function's parameter list, it means the
function has no parameters. For example:

Figure 6: Example for void

II.1.2. Data structure

• Structure:

In C, a structure is a keyword that defines a user-defined data type. A structure provides a data
type that may be used to combine objects of potentially disparate types into a single type. For
example:

Figure 7: Example for structure

• Array
Arrays are a form of data structure that may hold a fixed-size collection of elements of the
same type in sequential order. Although an array is used to hold data, it is frequently more
beneficial to conceive of it as a collection of variables of the same type.

Instead of declaring individual variables like number0, number 1, and number99, you declare a
single array variable called numbers and use numbers [0], numbers [1], numbers [99] to
represent individual variables. An index is used to access a specific element in an array.

All arrays are made up of memory regions that are connected in some way. The first element is
represented by the lowest address, while the last element is represented by the highest address.

8
Figure 8: Example for the array

• Function

Functional programming languages are a class of languages designed to reflect the way people
think mathematically, rather than reflecting the underlying machine. Functional languages are
based on the lambda calculus, a simple model of computation, and have a solid theoretical
foundation that allows one to reason formally about the programs written in them. (Goldberg,
1996)

Figure 9: Example for function

II.2. Statement needed in the program


• If-else statement: When the Boolean expression is false, an if statement might be followed by
an optional else statement.

Syntax: The syntax of an if...else statement in the C programming language is

if(boolean_expression) {

/* statement(s) will execute if the boolean expression is true */

} else {

/* statement(s) will execute if the boolean expression is false */

The if block will be run if the Boolean statement evaluates to true; else, the else block will be
executed.

9
Any non-zero and non-null values are presumed to be true in the C programming language,
whereas zero and null values are believed to be false.

Figure 10: Example for if-else

• For statement: A for loop is a repetition control structure that lets you design a loop that has to
run a certain number of times quickly.

Syntax: The syntax of a for loop in C programming language is −

for (int; condition; increment) {

statement(s);

Figure 11: Example for for-loop

• Do-while statement
Unlike for and while loops, which test the loop condition at the top of the loop, the do...while
loop in C programming checks its condition at the bottom of the loop.

A do...while loop is similar to a while loop, except for the fact that it is guaranteed to execute
at least one time.
Syntax
The syntax of a do...while loop in C programming language is −
do {
statement(s);
} while( condition)

Figure 12: Do-while statement

10
Because the conditional expression comes after the loop, the loop's statement(s) run once
before the condition is tested.
If the condition is true, the flow of control returns to do, and the loop's statement(s) are
executed once again. This method continues until the supplied condition is no longer true.

• Switch-case statement
A switch statement allows a variable to be tested for equality against a list of values. Each
value is called a case, and the variable being switched on is checked for each switch case.

Syntax
The syntax for a switch statement in the C programming language is as follows −
switch(expression) {
case constant-expression:
statement(s);
break; /* optional */
case constant-expression:
statement(s);
break; /* optional */
/* you can have any number of case statements */
default: /* Optional */
statement(s);
}

11
Figure 13: Switch-case example

III. Design
III.1. WBS
A work breakdown structure (WBS) is a deconstruction of a project that is visible, hierarchical, and
focused on deliverables. It's a useful diagram for project managers since it helps them to break down
the scope of their projects and visualize all of the activities needed to finish them.

The work breakdown structure (WBS) is a vehicle for breaking an engineering project down into
subprojects, tasks, subtasks, work packages, and so on. It is an important planning tool that links
objectives with resources and activities in a logical framework. It becomes an important status monitor
during the actual implementation as the completions of subtasks are measured against the project plan.
(Tausworthe, 1979)

12
Figure 14: The hierarchy diagram of the program

The program is divided into 5 sub-functions:

- Function 1: Enter student information


- Function 2: Find student by code
- Function 3: Show the student's highest GPA
- Function 4: Show the student’s lowest GPA
- Function 0: Exit the management program

13
III.2. Use case diagrams

Figure 15: Use case diagram

14
III.3. Flowchart

15
Figure 16: Flowchart for the main function

Figure 17: Flowchart for function calculation

Review: There are three phases in this flowchart to calculate the average of three match points.

16
- Step 1: Enter the three three-point values.

- Second step: Recipe:

Step 3: Save and print the AVG score on the console screen using the formula AVG = sum of three values
divided by three.

Rather than calculating AVG directly, we may first add the three values together and then divide by three
to get the average score. This method requires you to define a new variable "sum" and takes longer than
the direct method.

17
Figure 18: Flowchart for function enter student information

18
Review: This flowchart depicts the function of adding a student and includes three essential steps:

- Step 1: Select this choice, and the name of the case will show on the screen.

- Step 2: Enter the student's information, including ID, name, age, gender, and so on.

- Step 3: Save and print all of the data you entered on the terminal panel.

19
Figure 19: Flowchart for function find student by code

20
Review: In this function, you must declare a count variable I that will run from 0 to "n." The text code you
enter will be checked. If the list has the same string, the computer will display information about the
student who has this code.

21
Figure 20: Flowchart for function show the student highest GPA

22
Review: this function includes 3 steps:

- Step 1: declare and assign the first value is max.

- Step 2: compare with others, which value larger is assigned to the max.

- Step 3: Print this student who has the max GPA score on the console screen.

23
Figure 21: Flowchart for function show the student lowest GPA

Review: there are three phases to this function:

- Declare and assign the first value, which is min.

24
- Step 2: compare to others and assign the lesser amount to the maximum.

- Step 3: On the console screen, print the student with the lowest GPA.

IV. Evaluation
IV.1. General evaluation
We were able to completely create a student administration application with the essential powers by
applying the core information we had gained to the C programming language. Explanations and circles
help us save time and ensure consistency and accuracy. They are necessary, easy to get, simple to
hone, and operate remarkably effectively. The WBS and flowchart are constructed clearly and
consistently, breaking down the whole lesson into complete subroutines and satisfying all of the
teacher's criteria.

IV.2. Advantage and disadvantages of procedural programming


Advantage:

• The programmed simplicity, as well as the ease of implementation of compilers and


interpreters, make procedural programming ideal for general-purpose programming.
• A wide range of books and online course materials on tested algorithms are accessible, making
it easy to study as you go.
• Because the source code is portable, it may also be used to target a different CPU.
• It is not necessary to replicate the code because it may be reused in various portions of the
application.
• The memory need is also reduced using the Procedural Programming approach.
• The program's flow can be simply followed.

Disadvantage:

• When Procedural Programming is used, the computer code is more difficult to write.
• Because procedural code is frequently not reusable, it may be necessary to rebuild it if it is
required for usage in another application.
• Relationships with real-world items are difficult.
• The procedure is prioritized over the data, which may cause problems in data-sensitive
situations.
• Because the data is visible to the entire program, it is not very secure.

The most problematic aspect of procedural programming is that, while being a high-level language,
procedural code is slower than code written in a lower-level language. Processing also needs a higher level
of processing capacity than for other languages. This has had a direct impact on the outcomes of
procedural programming.

25
V. Conclusion
All of my reports are listed above. I used a knowledge foundation of basic ideas, such as • Basic
programming expertise, to create a faultless report.

• Understanding of sub-functions.
• Create a structure in the C programming language.
• Loop structures: for, do-while, while, and so on
• If-else, switch case: how to utilize the control and branching structure
• How to recognize a use-case and create a flowchart.

When the program is running, it may be assumed that it will be pretty comprehensive and complete.
but Different sorts of statements and functions must be integrated to create a program that fits all
requirements. However, the application will undoubtedly have defects and unpleasant features; to
address this issue, the required program update actions will be done.

Reference:
Tausworthe, R., 1979. The work breakdown structure in software project management. Journal of
Systems and Software, 1, pp.181-186.
Katz, J. and McGee, W., 1963. An experiment in non-procedural programming. Proceedings of the
November 12-14, 1963, fall joint computer conference, pp.1-13.
Goldberg, B., 1996. Functional programming languages. ACM Computing Surveys (CSUR), 28(1),
pp.249-251.
Chapin, N., 2003. Flowchart. Encyclopedia of Computer Science, pp.714-716.
Abdullah-Al-Wadud, M., 2016. {A Procedural Way of Teaching Procedural Programming
Language. International Journal of Education and Learning Systems, 1.

26

You might also like