Professional Documents
Culture Documents
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:
2
Table of Contents
SECTION 1: INTRODUCTION (P1) .................................................................................................................................. 6
1.1 Scenario: ............................................................................................................................................................ 6
1.2. Programing Language:.................................................................................................................................... 6
1.2.1. Definition: .................................................................................................................................................. 6
1.2.2. Today's most widely used programming languages: ............................................................................. 7
1.3. C Language: ................................................................................................................................................... 11
1.4. Procedural Programming: ............................................................................................................................ 12
1.4.1. Definition: ................................................................................................................................................ 12
1.4.2. Structure of Procedural Programming: ............................................................................................... 12
1.5. Key Features of Procedural Programming: ................................................................................................ 13
1.5.1. Predefined functions: .............................................................................................................................. 13
1.5.2. Local Variable: ........................................................................................................................................ 13
1.5.3. Global Variable: ...................................................................................................................................... 14
1.5.4. Modularity:.............................................................................................................................................. 15
1.5.5. Parameter Passing: ................................................................................................................................. 15
1.5.6. Procedure: ............................................................................................................................................... 17
1.5.7. Programming Libraries: ........................................................................................................................ 17
1.5.8. Programming paradigm:........................................................................................................................ 18
1.6. User requirements: ........................................................................................................................................ 18
SECTION 2: ANALYSIS (P2) .......................................................................................................................................... 19
2.1. Data Types:..................................................................................................................................................... 19
2.1.1 Integer Types ............................................................................................................................................ 21
2.1.2. Character Types ..................................................................................................................................... 22
2.1.3. Floating-Point Types .............................................................................................................................. 23
2.2. Data Structure: .............................................................................................................................................. 24
2.2.1 What is Data Structure: .......................................................................................................................... 24
2.3. Data types I choose for my assignment: ....................................................................................................... 26
2.4. Conditional statements in C:......................................................................................................................... 26
2.4.1. If statement .............................................................................................................................................. 27
2.4.2 If-else statement: ...................................................................................................................................... 29
2.4.3. Switch statement: .................................................................................................................................... 30
3
2.5. Loop statements in C: .................................................................................................................................... 32
SECTION 3: DESIGN (P3).............................................................................................................................................. 33
3.1 WBS: ................................................................................................................................................................ 33
3.2 Flowchart:........................................................................................................................................................ 35
3.2.1 Input student ID and grade of student: ................................................................................................. 35
3.2.1 Print student ID and grade of student: .................................................................................................. 37
3.2.2 Find max grade: ....................................................................................................................................... 38
3.2.3 Find min grade ......................................................................................................................................... 39
Reference .................................................................................................................................................................... 42
Table of Table
Table 1: Data types in C .............................................................................................................................................. 21
Table 2: Data types in my assignment ....................................................................................................................... 26
Table 3: Loop types ..................................................................................................................................................... 32
4
Table of Figures
Figure 1: Top 10 most popular progamming languages 2022 ...................................................................................... 6
Figure 2: Python Languages. ........................................................................................................................................ 7
Figure 3: Java Languages ............................................................................................................................................. 8
.Figure 4: SQL Languages ............................................................................................................................................ 8
Figure 5: C# Languages. ............................................................................................................................................... 9
Figure 6: Javascript Languages................................................................................................................................... 10
Figure 7: C Languages ................................................................................................................................................ 10
Figure 8: Structure of C Languages ............................................................................................................................ 11
Figure 9: Procedural Programming Languages. ......................................................................................................... 12
Figure 10: Example of Predefined functions .............................................................................................................. 13
Figure 11: Example of Local Variable........................................................................................................................ 14
Figure 12: Example of Global Variable ...................................................................................................................... 14
Figure 13: Example of Pass by Value ......................................................................................................................... 16
Figure 14: Example of Pass by Reference .................................................................................................................. 17
Figure 15: Example of Programming paradigm ......................................................................................................... 18
Figure 16: Data types in C .......................................................................................................................................... 19
Figure 17: The data types in C .................................................................................................................................... 20
Figure 18: Example of Integer .................................................................................................................................... 22
Figure 19: Example of Character ................................................................................................................................ 23
Figure 20: Example of Floating-Point ........................................................................................................................ 24
Figure 21: Classification of Data Structure ................................................................................................................ 25
Figure 22: Popular types of Data Structures ............................................................................................................... 26
Figure 23: Flowchart of If statement .......................................................................................................................... 27
Figure 24: If statement ................................................................................................................................................ 28
Figure 25: If statement ................................................................................................................................................ 28
Figure 26: Flowchart of If-else statement ................................................................................................................... 29
Figure 27: If-else statement ........................................................................................................................................ 29
Figure 28: If-else statement ........................................................................................................................................ 30
Figure 29: Flowchart of switch statement ................................................................................................................... 30
Figure 30: Switch statement ....................................................................................................................................... 31
Figure 31: Flowchart of Loop statements ................................................................................................................... 32
Figure 32: WBS .......................................................................................................................................................... 33
Figure 33: Flowchart input IDs and grade .................................................................................................................. 35
Figure 34: Flowchart print IDs and grade ................................................................................................................... 37
Figure 35: Flowchart find max grade.......................................................................................................................... 38
Figure 36: Flowchart find min grade .......................................................................................................................... 40
5
SECTION 1: INTRODUCTION (P1)
1.1 Scenario:
✓ A math teacher wishes to manage a class's grades. He asks me to support him in
creating a small application to accomplish this. He must enter student IDs and
grades and store this information in two separate arrays (integer array for IDs and
float array for grades). Then he must print all student IDs as well as their grades.
Finally, he must determine which student has the highest and lowest grade. My
program should have a menu with the options listed above. When an option is
completed, the program should return to the main menu so the user can select
another option. There should be a way to exit the program.
6
1.2.2. Today's most widely used programming languages:
1.2.2.1. Python:
• Python plays an important and seemingly irreplaceable role in modern life because it
is free, simple, easy to learn, and flexible... Python is also used in education because
it has more tools and metrics than other programming languages.
1.2.2.2. Java:
• Java is one of the market's oldest and most well-established languages. With benefits
such as easy search; rich API functions; powerful development tools; and free... Java
can also be found in and out of platforms, operating systems, and so on.
7
Figure 3: Java Languages
1.2.2.3. SQL:
• SQL is a data query language that all current database systems, including Oracle
SQL, MySQL, and SQL Server, must support.
8
1.2.2.4. C#:
Figure 5: C# Languages.
1.2.2.5. Javascript:
• This is another programming language that is relatively simple to learn and use.
Outside of browsers, JavaScript can be found in a variety of contexts, the majority of
which are connected applications and services.
9
Figure 6: Javascript Languages.
1.2.2.6. C:
Figure 7: C Languages
10
1.3. C Language:
✓ C is a procedural programming language. It was created for the first time in 1972 by
Dennis Ritchie. It was designed primarily as a system programming language for the
development of operating systems. The C language's low-level memory access, small
set of keywords, and clean style make it ideal for system programming, such as
operating system or compiler development. Many of the following languages have
inherited syntax and features from C, either directly or indirectly. The C programming
language serves as the foundation for many other languages, including Java, PHP,
JavaScript, and others. C++ is a near-superset of C (only a few programs will compile
in C but not C++).
11
• Recursive
• Expand
✓ In my opinion, the most significant advantage of C is its incredible interoperability.
The C program is only used on this one computer and with this one operating
system; it can be easily transferred to another machine or operating system. C is a
quick-loading programming language that can run on a wide range of
microprocessors. As a result, almost all computers now use the C programming
language. In contrast, C is only appropriate for high-performance applications or
system software. C became perplexed and difficult to deal with when confronted
with more complex situations.
12
1.5. Key Features of Procedural Programming:
1.5.1. Predefined functions:
❖ A function is a method in a program that can be called by its name. Built-in functions
are another name for predefined functions. They are a collection of subroutines that
perform specific functions. These functions are typically included in high-level
programming languages such as Python and C++, but they can also be loaded into the
programming language from registries or programming libraries.
13
Figure 11: Example of Local Variable
14
1.5.4. Modularity:
❖ Modularity refers to the use or application of modules, also known as chunks or
parts. It means breaking down a large problem into smaller modules in order to solve
it quickly. It entails dividing the program's functionality into independent smaller
parts, and each part can execute the specific function for which it was created.
1.5.5. Parameter Passing:
The pass by value mode employs in-mode semantics. Any changes made to
the perimeter are not transmitted to the caller when using this method.
Changes to the parameter are only reflected in the separate storage location,
and they have no effect on where the function is called.
15
Figure 13: Example of Pass by Value
• Pass by reference
In/out-mode semantics are used in this method. Changes to the parameter are
transmitted back to the location where the function is called using this
method.
16
Figure 14: Example of Pass by Reference
The name of the variable is passed in this type of parameter passing, allowing
it to be accessed and updated.
• Pass by value-result
17
1.5.8. Programming paradigm:
❖ Programming paradigms are different ways or styles of organizing a given program
or programming language. Each paradigm has its own set of structures, features, and
ideas about how to approach common programming problems.
1.6.2. As a teacher, I want to enter the IDs and grades of my students, so that I can see
some or all of them when I need them.
1.6.3. As a teacher, I want to print all student IDs together with their grades, so that I can
give them to each student's parents.
1.6.4. As a teacher, I want to know which student has the highest grade and lowest grades,
so that I can reward high-grade students and help low-grade students.
18
SECTION 2: ANALYSIS (P2)
2.1. Data Types:
❖ Each variable in C has a corresponding data type. Each data type has different
memory requirements and specific operations that can be performed on it. It
specifies the type of data that the variable can store, such as integers, characters,
floating points, doubles, and so on. The data type is a collection of data that has
fixed values, meaning, and characteristics.
19
Figure 17: The data types in C
❖ Different data types have different number ranges that they can store. These ranges
may differ from one compiler to the next. On the 32-bit GCC compiler, the ranges
are listed below, along with the memory requirements and format specifiers.
20
double 8 1.7E-308 to 1.7E+308 %lf
long double 16 3.4E-4932 to 1.1E+4932 %lf
Table 1: Data types in C
Note: The size of an integer data type is compiler-dependent; for example, when
processors are 16-bit systems, the output of int is 2 bytes. When using 32-bit processors,
it displays 2 bytes as well as 4 bytes.
21
Figure 18: Example of Integer
❖ Character data types allow their variables to store only one character. The character
has a storage capacity of one. It is the most fundamental data type in C. In almost
all compilers, it stores a single character and requires a single byte of memory.
• Range: (-128 to 127) or (0 to 255)
• Size: 1 byte
• Format Specifier: %c
22
Figure 19: Example of Character
23
Figure 20: Example of Floating-Point
❖ A data structure is used for more than just organizing data. It is also used for data
processing, retrieval, and storage. Data structures of various basic and advanced
types are used in almost every program or software system that has been developed.
As a result, we must be well-versed in data structures.
24
Figure 21: Classification of Data Structure
❖ Linear data structure: A linear data structure is one in which data elements are
arranged sequentially or linearly, with each element attached to its previous and next
adjacent elements.
Examples of linear data structures are array, stack, queue, linked list, etc.
• Static data structure: The memory size of a static data structure is fixed. A
static data structure makes it easier to access the elements.
An example of this data structure is an array.
• Dynamic data structure: The size of a dynamic data structure is not fixed. It can
be randomly updated during runtime, which may be considered efficient in terms
of the code's memory (space) complexity.
Examples of this data structure are queue, stack, etc
❖ Non-linear data structure: Non-linear data structures are those in which data
elements are not placed sequentially or linearly. We cannot traverse all of the
elements in a non-linear data structure in a single run.
Examples of non-linear data structures are trees and graphs.
25
Figure 22: Popular types of Data Structures
26
2.4.1. If statement
27
❖ It is a very powerful conditional statement. The If statement is in charge of changing
the flow of execution of a program. The If statement is always used in conjunction
with a condition. Before executing any statement within the body of If, the condition
is evaluated first. If statement syntax is as follows:
❖ The condition returns either true or false. True is always non-zero, and false is always
contains zero. Instructions can be a single line of code or a code block surrounded by
curly braces { }.
❖ The following program demonstrates how to use the if construct in C programming:
28
2.4.2 If-else statement:
❖ The if-else is statement is a more complex version of If. The following is the general
form of if-else:
❖ If the value of the test-expression is true in this type of construct, the true block of
statements will be executed. If the test-expression value is false, the false block of
statements will be executed. In any case, control will be automatically transferred to the
statements appearing outside the If block after execution.
29
❖ The following programs demonstrate how to use the if-else construct:
❖ We will assign a value to a variable and write a program to determine whether the value
is less than or greater than ten.
30
❖ The switch statement in C is an alternative to the if-else-if ladder statement, and it
allows us to perform multiple operations for the various possible values of a single
variable called switch variable. In this case, we can define multiple statements in
multiple cases for different values of a single variable.
❖ The syntax of switch statement in c language is given below:
31
2.5. Loop statements in C:
1 while loop
Repeats a statement or group of statements while a given condition is true. It tests the condition before
executing the loop body.
2 for loop
Executes a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
3 do...while loop
It is more like a while statement, except that it tests the condition at the end of the loop body.
I use for loop in input function to input grade and IDs of student.
32
I use for in function that prints out all IDs and scores
I use for to traverse the entire array to find the min grade and max grade.
I use a while loop to determine whether the user entered a valid score or not, and if not, the
user must re-enter it.
I use the do-while loop to create the menu, the choices and then re-enter the incorrect choices
in the main function.
34
3.2 Flowchart:
3.2.1 Input student ID and grade of student:
• Explanation:
Step 1: start
35
Step 2: Declare float grade[30], IDs[30], n,i=1
Step 3: Check condition i <= n
+ If true go to step 4
+ If false go to step 7
Step 4: Input IDs and grade
Step 5: Check condition grade[i] < 0 hoặc grade[i] > 10
+ If true go to step 6
+ If false increase i by 1 and go to step 3
Step 6: Print input grade again and go to step 4
Step 7: Stop
36
3.2.1 Print student ID and grade of student:
• Explanation:
Step 1: Start
Step 2: Declare float grade[30], IDs[30], n,i=1
37
Step 3. Check condition I <= n
+ If true go to step 4
+ If false go to step 6
Step 4. Print IDs and grade
Step 5. Increase i by 1
Step 6. Go back step 3
Step 7. Stop
3.2.2 Find max grade:
• Explanation:
38
Step 1. Start.
Step 2. Set max = grade[1]; declare int i = 1
Step 3. Check the condition i <= n
• If false, got to step 7
• If true, go to step 4.
Step 4. Check the condition “Max < grade[i]”:
• If true, set Maxgrade = grade[i] and go to step 5.
• If false, go straight to step 5
Step 5. Increase i by +1 then repeat step 3.
Step 6. End.
3.2.3 Find min grade
39
Figure 36: Flowchart find min grade
• Explanation
Step 1. Start.
Step 2. Set min = grade[1]; declare int i = 1.
Step 3. Check the condition “i <= n”:
• If false, go to step 7
• If true, go to step 4.
Step 4. Check the condition “min > grade[i]”:
• If true, go to step 5.
40
• If false, go to step 6.
Step 5: min = grade[i] and go to step 6
Step 6: Increase by 1 and go to step 3
Step 7: output min
Step 8: End
41
Reference
Imam, F. (2020). Procedural Programming | What should you know. [online] FinsliQ Blog. Available at:
https://www.finsliqblog.com/programming-languages/procedural-programming-what-should-you-know/.
iD Tech. (n.d.). What are Libraries in Programming? | Coding Definition & Examples. [online] Available
at: https://www.idtech.com/blog/what-are-libraries-in-coding.
tutorialstonight. (n.d.). Programming Paradigm in Details (With Examples). [online] Available at:
https://www.tutorialstonight.com/programming-paradigm [Accessed 23 Oct. 2022].
Learn Computer Science. (2021). What Is Programming Paradigm ? | Paradigm Types, Features
Explained. [online] Available at: https://www.learncomputerscienceonline.com/programming-paradigm/.
iD Tech. (n.d.). What are Libraries in Programming? | Coding Definition & Examples. [online] Available
at: https://www.idtech.com/blog/what-are-libraries-in-coding.
Lithmee (2018). What is the Difference Between Pass by Value and Pass by Reference. [online]
Pediaa.com. Available at: https://pediaa.com/what-is-the-difference-between-pass-by-value-and-pass-by-
reference/.
Nguyen, N. (2022). Bạn Cần Học Bao Nhiêu Ngôn Ngữ Lập Trình Để Trở Thành Developer? [online]
Glints Vietnam Blog. Available at: https://glints.com/vn/blog/ban-can-hoc-bao-nhieu-ngon-ngu-lap-trinh-
de-tro-thanh-developer/#.Y1Vi2HZBy3B [Accessed 23 Oct. 2022].
42