0% found this document useful (0 votes)
6 views22 pages

Prog102 - Assignment 1 frontsheet 2 (3)

This document outlines an assignment for a BTEC Level 5 HND Diploma in Computing, focusing on procedural programming. It includes sections on the introduction to procedural programming, problem analysis, design elements like flowcharts and use case diagrams, and evaluation of the solution. The assignment aims to develop a student information management program that efficiently handles grades and student data.

Uploaded by

hunghue378
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
0% found this document useful (0 votes)
6 views22 pages

Prog102 - Assignment 1 frontsheet 2 (3)

This document outlines an assignment for a BTEC Level 5 HND Diploma in Computing, focusing on procedural programming. It includes sections on the introduction to procedural programming, problem analysis, design elements like flowcharts and use case diagrams, and evaluation of the solution. The assignment aims to develop a student information management program that efficiently handles grades and student data.

Uploaded by

hunghue378
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/ 22

1

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Prog102: Procedural Programming

Submission date 21/6/2024 Date Received 1st submission

Date Received 2nd


Re-submission Date
submission

Student Name Tran Anh Duc Student ID GCH230530

Class PROG102 RE SU24 Assessor name Pham Danh Tuyen

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 Duc

Grading grid

P1 P2 P3 M1 M2 D1

1
2

2
3

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:

Assignment Brief 1 (RQF)

Higher National Certificate/Diploma in Computing

Unit Number and Unit 0: IT Fundamental & Procedural Programming


Title
Academic Year 2021
Unit Tutor
Assignment Title Analysis and Design a solution for procedural programming
problem
Issue Date
Submission Date
IV Name & Date

3
4

Learning Outcomes and Assessment Criteria

Table of Contents

1. INTRODUCTION .......................................... 5

1.1. Introduction about procedural programming.......................................... 5

1.2. Problem statement.......................................... 6

2. ANALYSIS ..........................................7
2.1. List data types, data structures needed in the problem
..........................................8
2.2. Conditional Statements ..........................................10
2.2.1 If statement..........................................11
2.2.2 If else statement..........................................12
2.3. Loop statements..........................................12
2.3.1 While loop..........................................13
2.3.2 For loop..........................................13

3. DESIGN ..........................................14

3.1. WBS ..........................................14

3.2. Use Case Diagram ..........................................15

3.3. Flowchart ..........................................16

3.3.1. Input student information..........................................16

3.3.2. Print all student information.......................................... 17

3.3.3. Print highest grade..........................................18

3.3.4. Print lowest grade..........................................19

4. EVALUATION..........................................20

4
5

ASSIGNMENT 1 ANSWERS

1. Introduction
1.1
Procedural programming is derived from imperative programming. Its concept is
based on procedure calls. Procedures are nothing but a series of computational
steps to be carried out. In Procedural programming, the execution of the
instructions takes place step by step. When you use Procedural language, you
give instructions directly to your computer and tell it how to reach its goal
through processes.

Procedural programming is a well-established paradigm characterized by a systematic


approach to problem-solving, where code is structured into distinct procedures or functions
that perform specific tasks.

Key characteristics of procedural programming include:

Top-down design: Problems are broken down into smaller, more manageable
subproblems, and each subproblem is solved using a separate procedure. This
approach is often described as "divide and conquer." (Brooks, 1995)

Sequential execution: Procedures are called and executed in a specific order, one
after the other. This makes it easier to understand the flow of control within a
program.

Data and procedures as separate entities: Data is stored in variables, and


procedures operate on this data. This separation promotes modularity and makes
code easier to maintain.

Global data: While not always ideal, procedural languages often allow data to be
declared globally, accessible by any procedure within the program. (Sebesta, 2012)

Emphasis on functions and procedures: The program's logic is encapsulated


within these reusable units, promoting code reusability and maintainability.

5
6

Predefined control structures: Procedural languages provide standard control


structures like loops (for, while) and conditionals (if-else) to govern the flow of
execution.

This structured approach to code organization makes procedural programming a suitable


choice for solving problems that can be broken down into a series of well-defined steps.
However, as problems become more complex, the global data and sequential nature of
procedural programming can lead to challenges in managing code dependencies and
maintaining large codebases.

Citations:

Brooks, F. P. (1995). The mythical man-month: Essays on software engineering.


Addison-Wesley Professional.

Sebesta, R. W. (2012). Concepts of programming languages. Pearson Education.

1.2 Problem statement


Scenario:
A math teacher wants to manage grades of a class. He asks you to help him to
write a small application to do that. He needs to enter student IDs, student’s
grades and store these information into 2 separate arrays (integer array for IDs
and float array for grades). Then he needs to print all student IDs together with
their grades. Finally, he needs to know which student has highest grade and
lowest grade. Your program should be menu based with the options above. When
an option is done, the program should go back to the main menu so he can choose
another option. There should be an option to quit program.

Problem: The problem of student information management is a difficult problem.


Manual management method has many disadvantages such as:
Time consuming, complicated, Information may be wrong and difficult to correct, If the
time is long, the document may be changed,d ifficult for searching, statistic, calculation.

6
7

We need to find a solution to this problem.

Solution: Student management program is a good choice


- Input information: name, ID, gender, score….
- Output information: Name, ID, gender, score of all student, maximum
score, minimum score,…
Advantages:
- Enter information quickly and accurately
- Information is stored for a long time
- Easy search, calculation, statistic

The student information and grade management problem is well-suited to procedural


programming for the following reasons:

1. Clear Sequential Nature: The problem requires sequential steps, from variable
declaration, grade input, to searching and displaying the highest/lowest scores.
Procedural programming, with its functions and sequential statements, aligns well
with this requirement.
2. Focus on Data Processing: The core of the problem is manipulating grade data.
Procedural programming, with its use of variables and arrays for data storage and
processing, is a natural fit.
3. Simplicity and Efficiency: For a problem that isn't overly complex, procedural
programming leads to code that is easy to read, maintain, and efficient.
4. Iteration: The problem requires the ability to iterate over multiple students to input
their grades. Procedural programming's for or while loops handle this requirement
directly.
5. No Need for High Abstraction: The problem doesn't necessitate the level of
abstraction and data encapsulation found in object-oriented programming.
Procedural programming is sufficient to solve the problem simply and effectively.

7
8

2. ANALYSIS

2.1. List data types, data structures needed in the problem

Int: An integer is a numeric literal (associated with numbers) without any


fractional or exponential part

Float: A floating-point literal is a numeric literal that has either a fractional form
or an exponent form.
Char: A character literal is created by enclosing a single character inside single
quotation marks.

Array:

Linear data structures in C, such as arrays, store elements in adjacent memory locations,
allowing for quick access using an index. These structures are designed to hold elements of
the same data type, and you can declare them with the syntax "Datatype varname [size];".
You can also declare and initialize an array at the same time.

8
9

Key word Explain Example


Integer Int Enter student ID 33, 11,34
number
Float Float Used to gender 5,7,2,4,…
grades for
students
Characters char Used to enter Nguyen Van A
student’s name
and gender

2.2. Conditional Statements

If statement

If statements are logical blocks used within programming. They’re conditional statements
that tell a computer what to do with certain information. In other words, they let a program
make ‘decisions’ whileit’s running.

9
10

Figure 1: Flow diagram of if

2.2.2 If-else statement

The if-else statement is used to perform two operations for a single condition. The if-else
statement is an extension to the if statement using which, we can perform two different
operations, i.e., one is for the correctness of that condition, and the other is for the
incorrectness of the condition. Here, we must notice that if and else block cannot be
executed simiulteneously. Using if-else statement is always preferable since it always
invokes an otherwise case with every if condition.

The if-else statement is valuable because it introduces decision-making into our code. It
lets our programs adapt and respond differently based on varying circumstances or user
input. For example, we could use it to:

• Validate input: Check if user input is valid before processing it.


• Customize output: Display different messages or results based on user choices.

10
11

• Control program flow: Decide which parts of the code to execute based on
conditions.
• Error handling: Take different actions in case of errors.
• Make choices in games: Determine the outcome of actions based on game rules.

Figures 2 : Flow diagram of if else

2.3 Loop statement


2.3.1 while loop

The do while loop is a post tested loop. Using the do-while loop, we can repeat the
execution of several parts of the statements. The do-while loop is mainly used in the case
where we need to execute the loop at least once. The do-while loop is mostly used in
menu-driven programs where the termination condition depends upon the end user

11
12

Figure 3: Flow diagram of while loop

2.3.2 For loop

The for loop is distinguished from other looping statements through an explicit loop
counter or loop

variable which allows the body of the loop to know the exact sequencing of each iteration

12
13

Figure 4: Flow diagram of for loop

3. Design

3.1 WBS

Figure 5: WBS of program

13
14

3.2. Use Case Diagram

14
15

Figure 6: Use case

15
16

3.3 Flowchart

3.3.1. Input student information

First flowchart to enter the student id, still follow the initial steps, but if you enter the Id

correctly, the program will show all the information and run the for loop, but if you enter
the

wrong Id, it will not show all information and will return to the original selection.

Figure 7: Enter student informaton student flowchart

16
17

3.3.2. Print all student information


This flowchart enter the number of students to create, then enter ID, grades data of
each student into the program.

Figure 8: Printing information of student flowchart

3.3.3. Print highest grade


17
18

This flowchart will use max to find the student's highest score, use float to assign
the score if max is less than student's score then that score will become max and the
program will run

Figure 9: Flowchart of highest Grade

18
19

3.3.4. Print lowest grade

This flowchart will use min to find the student's lowest score, use float to assign the score
if min is greater than student's score then that score will become min and the program will
run.

Figure 10: Flowchart of lowest Grade

19
20

4 EVALUATION

#Evaluate your solution (analysis, wbs, flowcharts)

-First: The code must work and run properly.

Quite simply, having your code run will be a prerequisite. If you write code that often
suffers from basic errors such as: compilation errors, memory overflow, over-
accessing the index of the array ... then of course your code is "fake". As a software
developer, I need to know exactly what you want, what the data storage structures are
and how the logic code handles the data, etc.

Once you understand what you want to do, it's time to write code in a programming
language. I will then use a programming language to express what I want, ranging
from organizing data to processing logic. “Clean code” is a must, in addition, I also
need to understand and control the interaction between your code and other
components in the system (from language, platform, architecture, ...).

Evaluate how procedural programming is applied to your problem (advantages,


disadvantages, difficulties).

-Second: The code must solve the problem the user asked for. we are the ones who
know how to analyze and clarify them.

-Third: New code must be compatible with existing ones and easily extensible

Assuming I need to add a new feature to the product, I integrate additional source code
into what is already there, I need to make sure that it does not affect what is already
running properly in the program. Don't make your code-based mess, lose consistency
and hard to control. Pay attention to design and programming principles, such as
SOLID.

Besides, pay attention to the possibility of reusing source code or extending new
features later. Don't let when implementing a similar feature in the future, I have to
clone the source code somewhere else and edit just a few small places. Designing
modules and applying the principle of “loose coupling” can help in these situations.

Fourth: Not only writing code for computers, code is also for humans.

Because software is always in need of maintenance, focus on the "cleanliness" of the


source code. It's not just a matter of commenting code, naming variables long or short,
code nesting too much, etc., but it also has to show your true intentions when
20
21

implementing and writing those lines of code. It's easy to say, but this can be an
extremely difficult task.

Remember, software development doesn't just stop with writing the initial code, it also
needs to be maintained and continued to develop later. Many other people are involved
in this cycle, not just you. Leave lines of code that people who come after you can
easily understand. Like any other thing or phenomenon, it is very difficult to properly
and fully appreciate it. However, with the motto of finding "easy to quantify" ways,
the above criteria will more or less help you visualize and evaluate the code you do,
at least help you know what you will have to do.

#Difficulties

It's not too difficult to use, but you need to learn carefully before writing to avoid mistake
and have to fix bugs many times

Mistakes when writing code

Do not split the code.

Prefer writing your own rather than referencing.

Google search all the time.

Think fast code is better than nice and readable.

Write code without a plan.

Have not checked input and output data.

No exception handling.

Don't know debugging yet.

21
22

References: GeeksforGeeks. “Decision Making in C (if , if..else, Nested if, if-else-


if ),” May 19, 2017. https://www.geeksforgeeks.org/decision-making-c-cpp. (Access:
22/06/2024)
GeeksforGeeks. “While Loop in C,” September 25, 2022.
https://www.geeksforgeeks.org/c-while-loop/. (Access: 22/06/2024)

GeeksforGeeks. “For Loop in C++,” November 11, 2019.


https://www.geeksforgeeks.org/cpp-for-loop/. (Access: 22/06/2024)

EDUCBA. “If Else Statement in C++ | How If Else Statement Works in C++?
(Examples),” January 18, 2020. https://www.educba.com/if-else-statement-in-c-plus-
plus/. (Access: 22/06/2024)
“What Is Procedural Programming - Naukri Code 360.” Accessed June 21, 2024.
https://www.naukri.com/code360/library/procedural-programming-everything-you-
need-to-know. (Access: 22/06/2024)

22

You might also like