Prog102 - Assignment 1 Tran Duc Phuong
Prog102 - Assignment 1 Tran Duc Phuong
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.
Grading grid
P1 P2 P3 M1 M2 D1
1
Summative Feedback: Resubmission Feedback:
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.
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)
4
I.2.1. Characteristics
• 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.
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)
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:
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:
• 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:
• 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:
• 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)
if(boolean_expression) {
} else {
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.
• 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.
statement(s);
• 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)
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
13
III.2. Use case diagrams
14
III.3. Flowchart
15
Figure 16: Flowchart for the main function
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.
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 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
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.
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