


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog 102 : Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Nguyen Anh Huy Student ID GCS Class GCS1007 Assessor name Huynh Thi My Trang 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 D
Grade: Assessor Signature: Date: Lecturer Signature:
C programing language is a general-purpose computer programming language. Dennis Ritchie created it in the 1970s, and it is still very popular and influential. Operating systems, device drivers, and protocol stacks have continued to use it, though application software has used it less frequently. The smallest microcontrollers and embedded systems to the largest supercomputers all use the programming language C. Procedural programming (PP) is a programming paradigm, derived from imperative programming, based on the concept of the procedure call. The procedures divide a large program into blocks of functions that are small enough contains a series of calculation steps to be performed. Each function has a start and an end point, and has its own data and logic. In the program, the functions work independently. Data is converted back and forth through function call parameters. Dividing a program into functions allows multiple people to participate in the program's construction. Each person constructs one or more functions independently of the other. In a procedural program, we only need to know which function can do specific tasks. It doesn't matter how it's done, as long as the function is reliable, you can use it without knowing how well it performs its function. This is called functional abstraction (aka specialization) and is the foundation of procedural programming. The characteristics of PP are:
Scenario: A teacher wants to manage grades of a class. He asks I to help him to write a small application to do that. He needs to enter student IDs, name, gender, birthday, grades (Math, Physical, Chemical, English, Computer Science), average score. Firstly, he needs to print all student IDs, name, gender, birthday, together with their grades. Secondly, he needs to delete student by No. in list. Thirdly, he needs to sort student list (by name/student ID) ascending/descending. Fourthly, he needs to find student by name/student ID, highest average grade and lowest average grade. Finally, he needs show student list. My 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.
b. Switch statements Switch statement acts as a substitute for a long if-else-if ladder that is used to test a list of cases. A switch statement contains one or more case labels that are tested against the switch expression. When the expression match to a case then the associated statements with that case would be executed. We have seen the way of using conditional statements such as if, if-else. if-else ladder, but the need for an additional way of dealing with conditional statements may seem unnecessary but based on the certain usage, switch case was defined to check for the single condition, and based on the multiple cases, code can be executed.
a. While loop This loop executes a statement or a block of statements until the specified boolean expression evaluates to false.
a. Split function Add student information Enter student information including name, student id, gender, birthday, subject scores. Delete student information Print out the current list and delete by No. Sorted student Sort student list by name/student ID Find student The function allows to search for students in 4 ways: student ID, name, lowest average score, highest average score Show student list Print student information including name, student id, gender, birthday, subject scores, average score.
b. Hierarchy diagram Hierarchy diagram
b. Flowchart ❖ Menu option Flowchart 1 : Menu option
Explain flowchart: Step 1: Start Step 2: Declare variable int key, bool mOption Step 3: Check the condition “mOption = true”
Explain flowchart: Step 1: Start Step 2: Parameter numOfStud, n and arrSt[] Step 3: Declare variable i Step 4 : Set variable i = numOfStud Step 5 : Check the condition “i < n”:
❖ Delete student Flowchart 3 : Delete student
❖ Function sort student
Explain flowchart: Step 1: Start Step 2: Parametter arrSort[], n Step 3: Declare variable I, j Step 4 : Set i = 0 Step 5 : Check the condition “i < n - 1”: