You are on page 1of 26

Higher Nationals in Computing

Unit 0: Procedural Programming


ASSIGNMENT 1

Learner’s name:
ID:
Class:
Subject code:
Assessor name:

Assignment due: Assignment submitted:


ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 0: Analysis and Design a solution for procedural programming problem

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Student ID

Class Assessor name

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

Grading grid
P1 P2 P3 M1 M2 D1
❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Signature & Date:


ASSIGNMENT 1 BRIEF

Unit Number and Title Unit 0: Procedural Programming


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

Learning Outcomes and Assessment Criteria

Pass Merit Distinction

LO1 Understand the principles of procedural programming


LO2 Be able to design procedural programming solutions

P1 Provide an introduction to M1 Discuss on characteristics D1 Critically evaluate the design


procedural programming and features of procedural of your solution against the
programming characteristics and features of
procedural programming.
P2 Identify the program units M2 Review the design of a
and data and file structures procedural programming
required to implement a solution.
given design

P3. Design a procedural


programming solution for a
given problem

Assignment Brief
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.
Task 1
To prove your programming ability to be appointed to this small project, please prepare an illustrated guide
on programming in general and a particular emphasis on procedural programming. Here you will need to
include introduction to computer programming languages and discuss key features of procedural
programming.
Task 2
Your next task is to do the analysis for the scenario mentioned above by doing the following subtasks
 Identify the variables and data types required in the program.
 Identify and describe 2 different selection structures, including the condition(s) to check; state why
they are needed and where they can be used in the context of the scenario.
 Identify and describe any iteration constructs.
 Split the program into functions (sub-functions) and draw a hierarchy diagram to illustrate the
structure of your program.

Task 3
You need to use a drawing tool to draw design diagram for your program, includes:
 A use case diagram for actions required
 Flow chart diagrams for: menu operation, printing IDs and grades, finding max grade and finding min
grade.
 Review / evaluate your design, state clearly pros vs cons and which needs to improve, using
characteristics of procedural programming as bases to discuss.

Write a report for 3 tasks above and submit the report to CMS in PDF format.

Submission Format
The submission is in the form of an individual written report. This should be written in a concise, formal
business style using single spacing and font size 12. You are required to make use of headings, paragraphs
and subsections as appropriate, and all work must be supported with research and referenced using the
Harvard referencing system. Please also provide a bibliography using the Harvard referencing system.
Table of Contents

P1 Provide an introduction to procedural programming

1.1 Introduction to computer programming languages..........................................1

1.2 Introduction to procedural programming.........................................................1

1.3 Key features ofprocedural programming..........................................................2

P2 Identify the program units and data and file structures required to implement a
given design

2.1 The variables and data types required............................................................3

2.2 External modules/functions required (stdio.h, string.h,etc., scanf, printf, etc.)


...................................................................................................................................7

P3. Design a procedural programming solution for a given problem

3.1 Use case diagram(s) for the actions required....................................................8

3.2 Flowchart(s) for the program design...............................................................10

3.3 Provide pseudo code listing(s) for the program..............................................15

Reference...................................................................................................................18
STUDENT’S ANSWERS

P1 Provide an introduction to procedural programming

1.1 Introduction to computer programming languages

A computer is a device can meet the needs of users through processing the data which is input
by us. However, the computer can not understand languages of human so computer
programming languagues are an important thing to connect the computer and users. There are
2 types of computer languages are low level languages and high level languages. The low
language or machine language are not nearly the human languages so it is hard to understand
clearly like Pascal,C,etc. On the other hand, high level languages are easy to comprehend and
present in many different computer languages. Like human has a lot of languages to
communicate with each other, likewise, the computer have many applications to communicate
with human like PHP,C#,Java,etc. Neither of which languages are the most useful and optimal
so each language has each own adventages and disadventages. For example, C# is a easy
language to study and use, it is fully supported by Window and IDE Visual Studio. However, it
only achieve the best effect on Window and users need to pay for IDE. Different from C#, PHP
can be used on a lot of operating systems like Linux and IIS-Window, with high processing
speed and high security so it is more popular than ASP but source code is not completed and it
only can be used on website.

1.2 Procedural Programming

Procedural Programming is a procession of input, handle and output the information which is
written by computer programmers. The method of developing programming is called an
application which keeps the code as consise as possible then performs the information which
programmers want.The procedural programming includes a series of computational steps to
be carried out by the application like Pascal, C, FORTAN, BASIC. This programming focuses on
processes, data and functions which are input and handled will be stored in same location. To

Page |1
complete a program, the programmers will code directly and test separately then gathered to
a form.

1.3 Key Features of Procedural Programming


There are 5 mains key features:

 Predefined functions: A predefined function is typically an instruction identified by a name.


Usually, the predefined functions are built into higher-level programming languages, but they
are derived from the library or the registry, rather than the program. One example of a pre-
defined function is ‘charAt()’, which searches for a character position in a string.
 Local Variable: A local variable is a variable that is declared in the main structure of a method
and is limited to the local scope it is given. The local variable can only be used in the method it
is defined in, and if it were to be used outside the defined method, the code will cease to work.
 Global Variable: A global variable is a variable which is declared outside every other function
defined in the code. Due to this, global variables can be used in all functions, unlike a local
variable.
 Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are
grouped together to conclude a larger task first. Every group of systems then would have its
own tasks finished one after the other until all tasks are complete
 Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions,
subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by
reference’, ‘pass by result’, ‘pass by value-result’ and ‘pass by the name’.

P2 Identify the program units and data and file structures required to
implement a given design

Somes key features:

2.1 if-else

Page |2
"if" structure is single selection structure; it selects or ignores a single action; if the condition is
true, the statement is executed; if the condition is false, the statement is skipped (indention is
optional but improves readability of program)

if (condition)
      statement;

"else" statement used to perform an alternative action; if

the condition is true, the statement1 is executed; if the

condition is false, the statement2 is executed

if (condition)
     statement1;
else
     statement2;

Page |3
switch (selection statement)
The switch statement allow us to select one from multiple options. It is especially useful when
we want to write a code that makes a selection based on an expression or a
variable. switch selection structure consists of a series of case labels and optional default case.

switch statement works by comparing the value of variable or expression within parentheses


with values specified in each case. If there is a match, the statements following the case will be
executed. If there is no match occurs, the default statement is executed. At the end of each
case, keyword break must be placed to exit from the switch immediately after statements
execution.

Page |4
while LOOP
while loop allows the repetition of a set of statements execution to continue for as long as a
specified expression (condition) is true. When the condition becomes false, the repetition
terminates and the first statement after the repetition structure is executed. Basically while
loop is similar to if selection in the sense that their set of statements are executed if the
condition is true. The different is while loop repeats the statement execution as long as the
condition is true and if selection does not have the repetition feature.

do while Loop
The do while loop is similar to the while loop. In the while loop, the loop condition is tested at
the beginning of the loop. The do while loop tests the loop condition at the end of the loop
structure or after the body of the loop is executed. Thus in do while loop, the compounded
statement will be executed at least once.

Page |5
for Loop Statement
Unlike while and do while statement, for statement handles all the details such as variable
initialisation, variable update and loop condition within single parantheses.

The statements to control the loop operation are separated. In the for statement, these
statements are combined together.

for statement structure has three (3) fields which are variable initialisation, loop condition and
variable update. These fields in the for statement are optional. we may omit variable
initialisation and place it elsewhere in the program for example before for statement. If loop
condition is omitted, C will assume that the condition is true thus resulting an indefinite loop.
Variable update may be ommited if we want to place it in the body of for statement.

The operation of the loop is controlled by the three expression between the for statement
parantheses.
Page |6
2.2 External modules/functions required (stdio.h, string.h,etc., scanf,
printf, etc.)

Structure of an external C module


A MicroPython user C module is a directory with the following files:

*.c and/or *.h source code files for your module.

These will typically include the low level functionality being implemented and the MicroPython
binding functions to expose the functions and module(s).

Input means to provide the program with some data to be used in the program
and Output means to display data on screen or write the data to a printer or a file.

C programming language provides many built-in functions to read any given input and to
display data on screen when there is a need to output the result.

In this tutorial, we will learn about such functions, which can be used in our program to take
input from user and to output the result on screen.
Page |7
All these built-in functions are present in C header files, we will also specify the name of header
files in which a particular function is defined while discussing about it.

scanf() and printf() functions

The standard input-output header file, named stdio.h contains the definition of the


functions printf() and scanf(), which are used to display output on screen and to take input
from user respectively.

When you will compile the above code, it will ask you to enter a value. When you will enter the
value, it will display the value you have entered on screen.

You must be wondering what is the purpose of %d inside the scanf() or printf() functions. It is


known as format string and this informs the scanf() function, what type of input to expect and
in printf() it is used to give a heads up to the compiler, what type of output to expect.

Ex:

#include <stdio.h>
int main()
{
  int n;

  printf("Input an integer\n");
  scanf("%d", &n);

  if (n%2 == 0)
    printf("It is an even number\n");
  else
    printf("It is an odd number\n");

  return 0;
}
Page |8
P3.

3.1 Identify requirements:

- Input student information

- Print all student information

- Print highest and lowest grade of students

- Select functions from menu

Page |9
3.2 Flowchart(s) for the program design

- Input student information

P a g e | 10
- Print all student information

P a g e | 11
- Print highest grade

P a g e | 12
- Print lowest grade

P a g e | 13
- Exit the program

P a g e | 14
3.3 Provide pseudo code listing(s) for this program

- Select menu functions


P a g e | 15
Begin

char option;

Display Menu:

0. Exit

1. Input student ID and Grade

2. Print student data

3. Print highest and lowest grade of student

while (option =='0')

End

- Input student infomations

Begin

Input number_student;

For (int i = 1; i<=number_student; i++)

Begin

input ID,grade;

add ID,grade to array[i];

End

End

- Print all student info

Begin

Input number_student;

For (int i = 1; i<=number_student; i++)


P a g e | 16
Begin

input ID,grade;

add ID,grade to array[i];

End

Display ID,grade in array[i];

End

- Print highest grade

Begin

i=1;

highest_grade =array[0];

while (i<numberOfGrade)

Begin

if(highest_grade< array[i])

Begin

highest_grade = array[i]

End

End

Display highest_grade;

End

- Print lowest grade

Begin

i=1;
P a g e | 17
lowest =array[0];

while (i<numberOfGrade)

Begin

if(lowest> array[i])

Begin

lowest = array[i]

End

End

Display highest_grade;

End

REFERENCES

 Sagar, B. (2020). Procedural Programming [Definition]. [online] Available at:


https://hackr.io/blog/procedural-programming [ Accessed 17 Oct. 2020]

P a g e | 18
 procedural3.blogspot.com (2014). Key features of procedural programming. [online] Available
at: http://procedural3.blogspot.com/2014/11/key-features-of-procedural-programming.html
[ Accessed 17 Oct. 2020]
 sciencehq.com (2013). Procedural oriented programming. [online] Available at:
https://www.sciencehq.com/computing-technology/procedural-oriented-programming.html
[ Accessed 17 Oct. 2020]
 myassignmenthelp.info (2014). Procedural programming Assignment. [online] Available at:
http://myassignmenthelp.info/assignments/procedural-programming-assignment-115664/
[ Accessed 17 Oct. 2020]
 locusassignments.com (2016). Procedural programming Assignment Sample. [online] Available
at: https://www.locusassignments.com/solution/unit-18-procedural-programming-assignment-
sample[ Accessed 17 Oct. 2020]

 lightbringer(2019). Programming paradigms – what is procedural programming? . [online]


Available at: https://www.tuannguyen.tech/2019/05/programming-paradigms-what-is-procedural-
programming/ [Accessed 17 Oct. 2020]

P a g e | 19

You might also like