





































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 19/10/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Phan Nhat Linh Student ID GCD Class GCD0905 Assessor name Phan Thanh Tra 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 Linh Grading grid P1 P2 P3 M1 M2 D
Grade: Assessor Signature: Date: Lecturer Signature:
A programming language is a set of commands, instructions, and other syntax that is used to write software. "High-level languages" refer to the languages that programmers use to write code. This code can be turned into a "low-level language" that the computer hardware can understand directly.
a. Definition A high-level language is a programming language that is meant to make computer programming easier. The term “high-level” refers to the separation of numerous processor operations from the actual application. Figure 2 : Examples of high-level languages b. Advantages of High-level languages
c. Disadvantages of High-level languages
a. Definition A low-level language works with the physical components and restrictions of a computer. It works to control a computer’s operational semantics and has no abstraction about computers. Figure 3 : example of low-level languages b. Advantages of Low-level languages
The syntax of the C programming language is relatively simple to grasp. It employs keywords such as if, else, goto, switch, main, and so on. This is the type of term that we all use in our daily lives to express meaning or make judgments. e, Portable The setup for the C language is about 3-5 MB. As a result, you may save this language on a floppy disk or a USB flash drive. It's simple to set up and use, and its result is an exe file that can be run on any machine without the need for any additional framework or software. Figure 5 : Advantages and Disadvantages of C language
a, Object-Oriented Programming Features (OOPS) Because the C language lacks object-oriented programming features, you must create your application entirely in procedure-oriented language. b, Run-Time Type Checking is Not Available There is no provision for run-time type verification in C. For example, if I send a float value and the receiving parameter is of integer type, the value will be altered and no error notice will be displayed. c, Namespace Feature Because C lacks namespace support, you won't be able to reuse the same variable name across scopes. You may be possible to reuse the same variable name if namespace features are present. d , Constructor and Destructor is not available Constructor and Destructor are not available in C since it lacks object-oriented capabilities. Constructor and Destructor are methods for creating and destroying objects. As a result, in C, you must manually build and destroy the variable, either via a function or another method. Our instructional course design is both practical and instructive. We provide resources at TekSlate to assist you in learning various IT courses. We provide both textual and video demonstrations. Explore Online C Tutorials for in-depth information and practical experience.
Procedural programming is a programming approach that allows for the division of functions into a number of processes. A huge program is split down into smaller, more manageable sections called procedures or functions in procedural programming. Functions take precedence over data in this case. A program in a procedural programming language consists of a series of instructions, each of which instructs the computer to perform a specific task, such as reading user input, performing the necessary computation, and presenting the results. When a program grows in size, it is divided into smaller components known as procedures or functions. For the completion of a given task, a number of functions are needed to be written. Because the same function is called from many locations, these functions prevent code duplication. Only medium-sized software programs are acceptable for this method. Figure 6 : A structure program There are two sorts of data in procedural programming: local and global. Local data is data that is contained within a function, while global data is data that is not included within any function. The only function where local data is defined has access to it. As a result, each function has access to both local and global data. Other functions cannot access the local data of one function. If two or more functions need to access the same data, it should be made global. Global data, on the other hand, is subject to being modified unintentionally by another programmer. The separation of data and functions performs a poor job of simulating real-world situations. As a result, procedural programming does not properly replicate a real-world system. Some programming languages that may implement procedural programming include COBOL, FORTRAN, C, and Pascal.
CHAPTER III: CHARACTERISTICS OF PROCEDURAL PROGRAMMING
In a program, a function is a procedure that may be invoked by its name. Built-in functions refer to predefined functions. They are a collection of subroutines that perform specialized functions. These functions are often included in high-level programming languages like Python and C++, but they may also be imported into the programming language via registries or libraries. Figure 8 : Some of the predefined functions in stdio.h header file (part 1) User-defined functions, on the other hand, are functions that are created by the user and must be loaded through a program, i.e., they are only present in that program and nowhere else. Concat(), for example, is a pre-defined function that allows you to combine the text of two strings into one new string. sqrt(), for example, returns the square root of any number passed to it as a parameter. The sqrt() function is a predefined function since it is built-in to Python and does not require explicit loading. They're helpful since they save the user from having to write a long line of code for a process and instead allow them to use a function. Furthermore, built-in features do not require any loading, making them extremely handy.
Figure 9 : Some of the predefined functions in stdio.h header file (part 2)
Variables are storage areas with specified names in computer languages. They can have values assigned to them by users. They are used to refer to a program's stored value. Local variables, also known as lexical variables, are variables defined within a method and may only be used/referenced within that method. As a result, their scope is limited to that technique, and they can't be utilized elsewhere. Other methods in the program will be unaware of the local variable created in this function if there are any. The software will throw an error if a local variable is used in another function. Figure 10 : Example of local variable The variable x, which is declared within the function, is only accessible within the function.
Figure 11 : Example of global variable Only global variables are accessible in certain computer languages, but most programming languages enable you to select between global and local variables. The 'global' keyword in some of these languages, such as Python and MATLAB, allows the creation of a global variable anywhere in the program, including inside the function. Some computer languages, particularly some modular programming languages, do not enable global variables at all.
Modularity refers to the use or use of modules, or pieces or components. It implies breaking down a huge problem into tiny chunks so that it may be solved quickly. It entails breaking down the program's functionality into smaller, independent components, each of which may do the job for which it was created. The work may be split down into smaller executable parts that can be readily turned into computer code thanks to the modular design. As a result, it is the breaking down of a program into smaller chunks that are easier to comprehend, alter, and administer. Modular programming in structural programming refers to the use of structured flow in low-level code.
Figure 12 : Example of modularity There are several advantages to programming in a modular fashion. The program is easier to work on, which is a significant benefit. It also allows you to invoke a piece of code many times. A single module can also be run independently of the rest of the program because it is a standalone component. The idea of modularity in procedural programming indicates that a big program is divided into smaller components, each of which performs a single task. These modules or components complete duties one by one before delivering the ultimate product.
Parameter passing is a programming language feature that allows parameters to be given to procedures or functions. The term parameter should not be confused with the term argument. The argument is the value that is provided to the function and is processed by it, whereas the parameter is the value that is specified in the function when it is declared. Multiple ways can be used to pass parameters to a function. The four parameter passing techniques are listed and discussed below:
In-mode semantics are used in pass by value mode. Any changes to the perimeter are not sent to the caller while using this approach. Changes to the parameter are solely reflected in the separate storage location, and they have no effect on where the function is invoked.