










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
pass phan p giup moi nguoi dc qua mon
Typology: Exams
1 / 18
This page cannot be seen from the preview
Don't miss anything!











Unit Number and Title Unit 0: IT Fundamental & Procedural Programming Academic Year 2021 Unit Tutor Assignment Title Analysis and Design a solution for procedural programming problem Issue Date Submission Date IV Name & Date Learning Outcomes and Assessment Criteria Pass Merit Distinction LO1 Understand the principles of procedural programming LO2 Be able to design procedural programming solutions P1 Provide an introduction to procedural programming M1 Discuss on characteristics and features of procedural programming D1 Critically evaluate the design of your solution against the characteristics and features of procedural programming. P2 Identify the program units and data and file structures required to implement a given design M2 Review the design of a procedural programming solution.
P3. Design a procedural programming solution for a given problem Assignment Brief Scenario: A math teacher wants to manage grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, student’s grades and store these information into 2 separate arrays (integer array for IDs and float array for grades). Then he needs to print all student IDs together with their grades. Finally, he needs to know which student has highest grade and lowest grade. Your 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. Task 1 To prove your programming ability to be appointed to this small project, please prepare an illustrated guide on programming in general and a particular emphasis on procedural programming. Here you will need to include introduction to computer programming languages and discuss key features of procedural programming. Task 2 Your next task is to do the analysis for the scenario mentioned above by doing the following subtasks
Task 1
Procedural Programming may be the first programming paradigm that a new developer will learn. Fundamentally, the procedural code is the one that directly instructs a device on how to finish a task dsin logical steps. This paradigm uses a linear top-down approach and treats data and procedures as two different entities. Based on the concept of a procedure call, Procedural Programming divides the program into procedures, which are also known as routines or functions, simply containing a series of steps to be carried out. Simply put, Procedural Programming involves writing down a list of instructions to tell the computer what it should do step-by-step to finish the task at hand.
The characteristics of procedural programming are: Procedural programming follows a top-down approach. The program is divided into blocks of codes called functions, where each function performs a specific task. Procedural programs model real-world processes as 'procedures' operating on 'data'.
The data and functions are detached from each other. The data moves freely in a program. It is easy to follow the logic of a program. A function can access other function's data by calling that function
Predefined functions: A predefined function is typically an instruction identified by a name. Usually, the predefined functions are built into higher-level programming languages, but they are derived from the library or the registry, rather than the program. One example of a pre-defined function is ‘charAt()’, which searches for a character position in a string. Local Variable: A local variable is a variable that is declared in the main structure of a method and is limited to the local scope it is given. The local variable can only be used in the method it is defined in, and if it were to be used outside the defined method, the code will cease to work. Global Variable: A global variable is a variable which is declared outside every other function defined in the code. Due to this, global variables can be used in all functions, unlike a local variable. Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are grouped together to conclude a larger task first. Every group of systems then would have its own tasks finished one after the other until all tasks are complete. Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions, subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by reference’, ‘pass by result’, ‘pass by value-result’ and ‘pass by the name’. Task 2: Data Types A data type is a type of data. Of course, that is rather circular definition, and also not very helpful. Therefore, a better definition of a data type is a data storage format that can contain a specific type or range of values The variables: A variable used to store data is a particular container type of data (like integer, float, string, etc..). Variables must be given a name. The variable name can be made up of upper-case or lower-case letters (A – Z or a – z), number characters (0 – 9), or an underscore (‘_’). There is one crucial restriction though: a variable name cannot start with a numeric character. Variable names are case-sensitive in C, in other words “value” and “Value” are different variables. It is a bad idea to define variables with names that are
If else: An if statement can be followed by an optional else statement, which executes when the Boolean expression is false Syntax: if (condition){ //one or more statements; }else { //one or more statements; Example switch case: A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.
If-Else-If: else-if statements in C is like another if condition, it's used in a program when if statement having multiple decisions. Syntax: if(test_expression) { //execute your code } else if(test_expression n) { //execute your code } Example:
IV. Split the program into functions (sub-functions) “A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. How you divide up your code among different functions isup to you, but logically the division is such that each function performs a specific task. A function declaration tells the compiler about a function's name, return type, and parameters. A function definitionprovides the actual body of the function. The C standard library provides numerous built-in functions that your program can call. For example, strcat() to concatenate two strings, memcpy() to copy one memory location to another location, and many more functions.”
1. Modules the parts of a function Return Type − A function may return a value. The return_type is the data type of the value the functionreturns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void Function Name − This is the actual name of the function. The function name and the parameter listtogether constitute the function signature. Parameters − A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type,order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters. Function Body − The function body contains a collection of statements that define what the function does. Task 3:
Breaking work into smaller tasks is a common productivity technique used to make the work more manageable and approachable. For projects, the Work Breakdown Structure (WBS) is the tool that utilizes this technique and is one of the most important project management documents. It singlehandedly integrates scope, cost and schedule baselines ensuring that project plans are in alignment. The Project Management Institute (PMI) Project Management Book of Knowledge (PMBOK) defines the Work Breakdown Structure as a “deliverable oriented hierarchical decomposition of the work to be executed by the project team.” There are two types of WBS: 1) Deliverable-Based and 2) Phase-Based. The most common and preferred approach is the Deliverable-Based approach. The main difference between the two approaches are the Elements identified in the first Level of the WBS.
The code can be reused in different parts of the program, without the need to copy it Through Procedural Programming technique, the memory requirement also slashes The program flow can be tracked easily Disadvantages The program code is harder to write when Procedural Programming is employed The Procedural code is often not reusable, which may pose the need to recreate the code if is needed to use in another application Difficult to relate with real-world objects The importance is given to the operation rather than the data, which might pose issues in some data-sensitive cases The data is exposed to the whole program, making it not so much security friendly There are different types of programming paradigm as we mentioned before, which are nothing but a style of programming. It is important to understand that the paradigm does not cater to a specific language but to the way the program is written. Below is a comparison between Procedural Programming and Object-Oriented Programming. Reference: