










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
assignment procedural programming
Typology: Assignments
1 / 18
This page cannot be seen from the preview
Don't miss anything!











Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date 10/7/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Pham Duc Phu Trong Student ID GCH Class GCH0907 Assessor name Do Tien Thanh 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 P4 M1 M2 D
Grade: Assessor Signature: Date: Lecturer Signature:
5.2 “While” and “Do-While” loop statement:...................................................................................................... 9 5.2.1 Purpose in program:............................................................................................................................... 9 5.2.2 “While” loop statement:....................................................................................................................... 10 5.2.3 “Do – While” loop statement:............................................................................................................... 10 III. Design:.................................................................................................................................................................. 11 1 WBS:................................................................................................................................................................... 11 2 Flowchart:........................................................................................................................................................... 12 IV. Evaluation:............................................................................................................................................................ 18 V. Conclusion:............................................................................................................................................................ 18 I. Introduction:
1. Introduction about programming language: Verma (2015) pointed out “A computer or a system is operated by given a set of rules and instruction to perform some tasks. These set of rules and instructions can control the working of computer or any automated and/or manipulated machine. To control the computer system using these sequential set of grammatical rules are known as programming language. In other words, ‘A programming language is a vocabulary and a set of grammatical rules for instructing a computer system to perform any specific task’. Hence we can say that a programming language plays a very important role to control and operating a computer system.” And we have some of programming languages: Figure 1 An example for programming languages (Tech 2021)
2. Introduction about procedural programming: 2.1 General concepts: 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 task in logical steps. 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, sub-program and simply comprise a set of actions to be carried out, based on the concept of a procedure call. (Bhatia 2021) 2.2 Characteristics: The characteristics of procedural programming will have: _ A huge program is decomposed into smaller, more manageable procedures or functions. This reduces code duplication, making the code more readable and maintainable (Nguyen T.,2019). _ Global variables allow different functions to share data. Because functions are totally segregated, we must declare data in the upper scope if we want to share it (Nguyen T.,2019). _ Global data can be changed by functions. Because global data is transmitted from function to function, global data in function chains may be altered during the transformation (Nguyen T.,2019). _ Methodology from the top down. As previously said, procedural programming employs a top-down approach, with workflow moving from top to bottom (Nguyen T.,2019). 2.3 Features: The key features of procedural programming are given below: 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 location in a string. (Bhatia 2021) Figure 2 :procedural programming description
Data types Purpose in program Int To enter an integer number: number of students, age, ID Float To enter a real number of students grades and save, display average grades because the grades must be float data types Char To enter name, gender 1.2. Reference data types: Data types Purpose Array Store information of many elements like name, age, … after enter from keyboard.
2. Data structure: Data structure used to declare data types and variables of one student like ID, name, age, …. in order to help the coder can use each of variable more easily in another task. The coder does not declare variable again in other function, they can recall it. 3. Assignment statement: Assignment statement is a statement assigns the value to variable. (int a = 5;). 4. Conditional statement: 4.1 If, if else, else if, else conditional statement: 4.1.1 Purpose in program: To set conditions for rank of members (Distinction or Merit or Pass or Fail) and arrange members with the average grades.
4.1.2 Example: We use “if” command when we want to set condition for the target, if the target is valid then the code inside “if” will be run. If the target does not valid, a program will consider to next condition is “else if” and do the same part with “if” and if the target do not valid in “else if” then program will run in the last condition is “else”. This condition, we can consider it is default which means if all other conditions is not valid, “else” command will be run. 4.2 Switch case conditional statement: 4.2.1 The purpose in program: To give choices for users if they want to choose any options like: Enter member information, display members information, … 4.2.2 Example :
5.2.2 “While” loop statement: “While” loop is the loop similar with “for” loop. The code will be considered with the condition immediately when the “While” loop is start. When the code inside “while” still correct, the “while” loop still be run. And it will stop until the number of executions reaches to the limited. 5.2.3 “Do – While” loop statement:
“Do – while” loop still have the same function with “while” loop, but we can distinguish two types of loops because they have a difference. If “while” loop will be considering the condition immediately when “while” is start, then “Do- while” loop will be do the first times the code of loop no matter the condition is valid or not. If the condition is not valid, the loop will be stop at the second times. The program above is an example for “Do – while” loop. III. Design:
Explain for WBS: Menu will have 4 functions: _ Function 1: Enter student information: enter a basic information of student like name, ID, … _ Function 2: Display student information: my program will counting the average grades first and will display the student information with the average grades later. _ Function 3: Arrange student with the average grades: arrange first and print it to the screen later. _ Function 4: Result of student: access result of students first and print it to the screen later.
This is switch case flowchart describe about the choices in main menu of main program. The user can choose any case and program will lead to function. Program has 6 choices include 4 choices will be represented by 4 functions below and 2 choice is case 0 and default will code inside switch case. Each of function maybe has a sub-function.
This flowchart is a function describe about N people will enter N times of their information into program. For example: N = 2, we will have 2 people and each of people will enter name, ID, age, gender, … one times. The purpose is collected and stored member information. YES
This flowchart is a function describe about the sub-problem will print to the screen the information of member. We initiate “Count” = 0 and enter the maximum value N from keyboard. Then we set the condition for “Count”. If the number of executions of count = N – 1, the program will print to screen information of members until the condition is not correct then the loop will stop.
This flowchart is a function to arrange the member with average grades from the smallest average grades to the highest average grades and do the opposite. We initiate “Count 1” and “Count 2”. Then we set condition: if a[count 1] > a[count 2]. a[count 1] and a[count 2] is the average grades, then we will declare a temporary variable and assigns it equal with a[count 1]. This time “temp” will have a value is a[count 1]. Then we continue assign a[count 1] = a[count 2], therefore a[count 1] will have a value of a[count 2]. End the last, we assign a[count 2] equal with “temp”. This time, the value of a[count 1] and a[count 2] have been converted to each other. Then we can find a bigger average grade and arrange it.