











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
An introduction to procedural programming, explaining what it is, its key features, and the advantages and disadvantages of using this programming model. It also covers the concept of predefined functions, parameter passing, and data types in C, as well as the use of variables and iteration constructs such as while, for, and do-while loops.
Typology: Assignments
1 / 19
This page cannot be seen from the preview
Don't miss anything!












Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PRG102: Procedural Programming Submission date 19 June 2022^ Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Thai Van Chien Student ID GCH Class GCH1103 Assessor name Lai Manh Dung 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
Grade: Assessor Signature: Date: Lecturer Signature:
Task I. Introduction to Procedural Programming
1.1 What is Procedural Programming? Procedural programming may be the first programming model a new developer will learn. Basically, the procedure code is the code that directly instructs the device how to complete a task in reasonable steps. (Bhatia, 2022) This model uses a top-down linear approach and processes data and procedures like two different entities. Based on the concept of a procedural call, Procedural programming that divides the program into procedures, also known as routines or functions, simply contains a series of steps that are taken. As a program grows in size, it is divided into smaller units called procedures or functions. To complete a certain task, several functions are expected to be written. Since the same function is called from different locations, these functions prevent code duplication. Only medium-sized software systems are suitable for this technique. To put it simply, Procedural programming involves writing down a list of instructions to let the computer know what it must do step by step to complete the task at hand. 1. Procedural Programming
1.2 Introduction to Computer Programming Languages A programming language is a set of commands, instructions, and other syntax that is used to develop software. The languages used by programmers to write code are referred to as "high-level languages." This code can be turned into a "low-level language" that is immediately recognized by computer hardware. (Hemmendinger, 2021) There are two classifications:
The problem that need to resolve by making a small application is about Student Management: A math teacher wants to manage the grades of a class. He asks you to help him write a small app to do it. He needs to enter the student's full name, the student's score, and store this information in two separate arrays (integer array for full name and float array for grades). Finally, he needs to know which student has the highest and lowest grades. Your program must have a menu based on the options above. When an option is made, the program will return to the main menu so that he can choose another option. There should be an option to exit the program. Task II. Analysis of variables, data types, structure and usage
A variable is nothing more than a name for a storage space that our programs may access. In C, each variable has a distinct type that determines its memory size and layout, as well as the range of values that may be stored in that memory and the set of operations that can be done on it. (tutorialspoint, 2022) Variable names can contain letters, digits, and underscores. It must start with a letter or an underline. Because C is case-sensitive, the upper and lowercase characters vary. The following basic variable types will be based on the preceding chapter's basic types: No. Type & Description 1 char Typical is a single octet (a byte). It's a kind of integer. 2 int The most natural size of the integer for the machine. 3 float A single-precision floating point value. 4 Double A double-precision floating point value. 5 Void Represents the absence of type. There are also various naming conventions for C variables: 1 .1 Variable definition The variable definition tells the compiler where and how much storage space to create for the variable. The variable definition specifies a data type and contains a list of one or more variables of that type as follows:
type variable_list; Here, the type must be a valid C data type including char, w_char, int, float, double, bool or any object defined by the user; and variable_list may include one or more identifiers separated by comma. Some valid declarations are displayed here: int i, j; char c; float f; double d; The line int i, j; declares and defines the variables i, j; which instruct the compiler to create variables named i, j of type int. Variables can be initiated (assigning the original value) in their declaration. The initializer consists of an equal sign followed by a constant expression as follows: type variable_name = value;
case y: // code block break; default: // code block } (W3school, n.d.) In my program, I use it to specify several choices that users may report and utilize in the "Menu options" section. For example, 1 is let the user Edit student, 2 for Delete student and 3 is Back to main menu. 2.2 If – else a) If Statement The if statement is used to check a supplied condition and conduct some operations based on the correctness of that condition. It is often employed in scenarios when we need to run multiple operations for distinct situations. The syntax of the if statement is shown below. b) If – else Statement The if-else statement is used to do two actions for a single circumstance. The if-else statement is an expansion to the if statement that allows us to do two separate actions, one for the correctness of the condition and the other for the incorrectness of the condition. We must keep in mind that the if and else blocks cannot be run concurrently. Using an if-else statement is usually preferable since it always invokes an otherwise case with every if condition. The syntax of the if-else expression is shown below.
In my program, the "if" statement is used to identify the highest or lowest mark in memory that users have entered.
You may encounter situations where a block of code needs to be executed several times. In general, the statements are executed sequentially: The first statement in a function is executed first, followed by the second statement, etc. A repeating statement allows us to execute a statement or a group of statements over and over again. Here's the general form of repeating statements in most programming languages: (tutorialpoint, n.d.) 3.1 While The loop while in programming C repeatedly executes a target statement as long as a given condition is correct. while(condition) { statement(s); }
3.3 Do…while In contrast to for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming tests the loop condition at the bottom of the loop. A do...while loop is similar to a while loop in that it is guaranteed to run at least once. The syntax of a do...while loop in C programming language is: do { statement(s); } while( condition ); (tutoralpoint, n.d.) 6 Flow diagram in Do...while In the main body of my program, I employ the do...while loop. The goal of constructing the menu. If a digit is selected outside of the program menu. The loop will be executed by the software.
7 Hierarchy Diagram In my program:
Step 10: Read choice 4 Step 11: Print the value step 4 stored and go to step 2. Step 12: Read choice 0 Step 13 Print the value in choice 0, stored and then go to step 2. Step 14: Stop, Exit programing. 2.1 Display Explain flowchart: Step 1: Start Step 2: Set char fullname[100][31], float mark[100], size, i = 0. Step 3: Check the condition; if true, Go To step 4; if false go to step 5. Step 4: Print the fullname, mark. Step 5: i = i + 1. Step 6: Repeat step 3. Step 7: Next option. Step 8: Stop.
2.2 Find highest and lowest grades Explain flowchart: Step 1: Start Step 2: Set float mark[100], int I; imax = 0, imin = 0, size. Step 3: Check the condition, if true go to step 4, if false go to step 5. Step 4: Check the condition, if true go to step 6, if false go to step 5. Step 5: i = i + 1. Step 6: Check condition, if true go to step 7 , if false go to step 5. Step 7: Assign imax = i, imin = i Step 8: Print mark[imax], mark[imin]. Step 9 : Repeat step 3. Step 10: Next option. Step 11: Stop.
c) Improve:
Procedural Programming [Definition] (2022). Available at: https://hackr.io/blog/procedural-programming (Accessed: 7 June 2022). What are the characteristics of procedural programming? | KnowledgeBoat (2022). Available at: https://www.knowledgeboat.com/question/what-are-the-characteristics-of-procedural-programming-- 28311496451138200 (Accessed: 7 June 2022). Variables and Data Types - Writing Word Macros, Second Edition [Book] (2022). Available at: https://www.oreilly.com/library/view/writing-word-macros/9781565927254/ch05s04.html (Accessed: 7 June 2022). C - Variables (2022). Available at: https://www.tutorialspoint.com/cprogramming/c_variables.htm (Accessed: 7 June 2022). C - switch statement (2022). Available at: https://www.tutorialspoint.com/cprogramming/switch_statement_in_c.htm (Accessed: 7 June 2022). C if else Statement (2022). Available at: https://www.javatpoint.com/c-if-else (Accessed: 7 June 2022). C - Loops (2022). Available at: https://www.tutorialspoint.com/cprogramming/c_loops.htm (Accessed: 7 June 2022).