

























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
Procedural programming đạt điểm M
Typology: Thesis
1 / 33
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 Trương Trần Quang Thắng Student ID GCD Class GCD1103 Assessor name Phan Thanh Trà 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
Summative Feedback: Resubmission Feedback: Grade: Assessor Signature: Date: Lecturer Signature:
Figure 1. Statistics of 2019
2. Programming high-level: Any programming language that makes it possible to create programs in a much more user-friendly environment and is typically independent of the hardware architecture of the computer is referred to as a high-level language. A high-level language is more abstracted from the computer and concentrates on the programming logic rather than the supporting hardware, such as register usage and memory addressing. Figure 2 .High level programming languages 3. Low-level languages: A programming language known as a low-level language works with the limitations and hardware of a computer. It operates to control a computer's operational semantics and has no (or very little) abstraction in relation to computers. A computer's native language is another name for a low-level language. **II. C programming language
2. Features: Figure 3 .Features of C language **III. Procedural programming:
3.3. Global variable: In contrast to local variables, global variables operate differently. Global variables are accessible to developers in almost all functions. In contrast to a global variable, which is visible across the whole programming language, a local variable only exists within a predefined scope. Figure 6 .Global variable 3.4. Parameter passing: The data values that are transferred from each function in a series are known as parameters. Developers that use parameter passing pass input parameters to a module or device and get output parameters back. Parameters can be passed to functions and procedures via this technique. 3.4.1. Important methods of parameter passing: 3.4.1.1. Pass by value: Utilizing in-mode semantics is this way. Formal parameter changes are not sent back to the caller. Any changes to the formal parameter variable made inside the called function or method will only have an impact on the separate storage location and not the real parameter in the calling environment. Call by value is another name for this technique. Figure 7 .Call by value
Figure 8 .Call by value Figure 9 .Output of call by value 3.4.1.2. Pass by reference (aliasing): This method employs the semantics of in/out-mode. Through parameter passing, changes made to formal parameters are returned to the caller. The formal parameter obtains a reference (or pointer) to the actual data, thus any changes to the formal parameter are reflected in the actual parameter in the calling environment. Another name for this mechanism is call by reference. This approach is effective in terms of time and distance.
Figure 12 .Output of call by reference 3.5. Modularity: The structure of modularity is when a developer breaks down the functionality of their code into a number of smaller components. Then, the programmer can access these blocks, which are frequently referred to as methods or functions in procedural programming languages, by calling them in their code. 3.6. Procedures: A procedure is a way of carrying out a work that includes steps and instructions for every part of the job. Once developed, procedures are frequently followed consistently to ensure a common understanding of what personnel should do in various situations. In order for staff to follow procedures effortlessly and for new hires to use them as a resource for learning how the office runs, those who develop procedures frequently strive for maximum specificity. Each aspect of a firm may have its own procedures, but you may encounter them through training manuals, information sessions, and guided tutorials. Example: Client check-in emails are a crucial component of our business. We service a number of accounts concurrently, so it's important to keep track of the progress we're making with each customer to make sure we're giving them all they require. The two main personnel categories most likely to use this approach regularly are account executives and sales reps. The procedures for sending a check-in email to your clients will be outlined in this procedure, including how to address them, what to include, and how to sign off. The following materials are required for this process: a computer internet access your company email account a client list with email addresses Steps for sending check-in emails to clients: Find the client's email address to check in with. Identify the services we rendered to the client. Open a new email draft in your company's email program.
Include the client's first name or their title and last name in the salutation when addressing the email to them. In the first paragraph of the email, mention the service we offer to the client using the following words: "Just wanted to give you an update on the ____ we did for you on. In the email's second paragraph, provide an extra service by saying something like, "We also provide __ services for all of your __ needs." Use words like these to invite the client to get in touch with you: "You may reach out to me at any time with any 3.7. Programming libraries: A library is a group of documents, applications, scripts, routines, or other pieces of code that can be used as references in computer programming. The programmers who created the programming language may have even created these libraries, which are more sophisticated than routines and optimized. Example: Figure 13 .stdio.h library 3.8. Programming paradigm: Programming paradigm is a word used to describe a general method of writing program code. The procedural programming paradigm divides program code into distinct chunks called procedures, each of which performs a specific task. Procedures, which are sometimes known as subroutines or functions, include a number of computational processes that must be completed in the order determined by the programmer. A purely procedural language is one like the programming language C. Numerous programming languages do, however, allow various paradigms. For instance, the well-liked general-purpose programming language Python enables you to write code that is procedural, object-oriented, or functional. Examples of Procedural programming paradigm: C: developed by Dennis Ritchie and Ken Thompson IV. User requirement: As a teacher, I want to enter my students' IDs and grades so that I can access any or all of them when I need to. As a teacher, I want to print all student IDs together with their grade so that I can send grades to the parents of the students.
Numerous books and online courses on tried-and-true algorithms are accessible, making it simpler to pick things up as you go. Because the source code is portable, it can also be used to target a different CPU. Without having to copy it, the code can be used in multiple areas of the application. Additionally, reduced by using procedural programming is the memory need. Tracking the program flow is simple.
2. Disadvantages: When procedural programming is used, writing the program code is more difficult. Because procedural code is frequently not reusable, it could be necessary to rebuild it if it needs to be used in another application. Difficult to link to objects in the actual world The procedure is given more importance than the data, which could cause problems in particular circumstances where the data is sensitive. Because the data is accessible to the entire program, it is less security-friendly. **B. ANALYZE THE SITUATION: P I. Variables and Data Types
Figure 16 .declared with a specific value
2. Data types: A variable's data type and the kinds of mathematical, relational, and logical operations that can be performed on it without producing an error are classified as data types in programming. For instance, a data type called a string is used to categorize text, while a data type called an integer is used to categorize whole numbers. Figure 17 .Data types 3. Array: An array is a grouping of data elements of a similar sort that are kept in close proximity to one another in memory. In the C programming language, arrays are a derived data type that may contain primitive data types like int, char, double, float, etc. Additionally, it has the capacity to store a variety of derived data types, including pointers, structures, and so forth. The following attributes are present in the array: An array's elements all have the same data type and size, which is int = 4 bytes.
Student has lowest score Mingrade Float Student’s grade is a real number from 0 to 10 Option n Integer Option is a number from 1 to 5 Figure 18 .Data types I choose for my assignment II. Conditional statement (P2):
1. If : The if statement is used to examine a given condition and carry out actions based on whether or not it is true. It is frequently employed in situations where we must carry out several procedures under various circumstances. Below is a list of the if statement's syntax. Figure 19 .Flowchart of If condition 2. If … else statement: There might be an optional else block in the if statement. The if..else statement has the following syntax:
Figure 20. Syntax of if - else How if...else statement works? If the test expression is evaluated to true, statements inside the body of if are executed. statements inside the body of else are skipped from execution. If the test expression is evaluated to false, statements inside the body of else are executed statements inside the body of if are skipped from execution. 3. Switch-case: In C, the switch statement is an alternative to the if-else-if ladder statement that enables us to do several operations for the various potential values of a single variable called the switch variable. Here, we can define different statements in a variety of situations for varied values of a single variable. The following is the syntax for the switch statement in the C language: Figure 21 .Syntax of switch-case