






















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
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.
Typology: Assignments
1 / 30
This page cannot be seen from the preview
Don't miss anything!























Date: 9/2/
Class: GCS1003B | ID: GCS
ASIGNMENT 1
ASSIGNMENT 1 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date 22 /02/2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name TRAN THE HAO Student ID GCS Class GCS1003B Assessor name LE NGOC THANH 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
Assignment Brief 1 (RQF)
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 P2 Identify the program units^ procedural programming. 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
A. Introduction: I. Programing language:
A programming language is a set of symbols, grammar, and rules with which people can translate algorithms into programs that will be executed by a computer. Programmers use programming languages to communicate with machines. Most programs have a set of highly structured rules. The main categories of programming languages are low-level language (Machine languages, Assembly language) and high-level language.
Machine language is a collection of binary digits, orbits, that the computer reads and interprets. Machine language is the only language a computer can understand directly. Machine language is a language that supports machine-side programming or does not provide human-side programming. It consists of (binary) zeros and ones. Each statement in a program is represented by a numeric code, and numeric addresses are used throughout the program to refer to locations in computer memory. Microcode allows some of the more powerful machine-level instructions to be expressed in the form of a set of basic machine instructions.
A high-level language is a language that supports the human and application side of programming. A language is a machine-independent way of specifying the sequence of operations required to accomplish a task. High-level language lines can perform powerful operations and correspond to dozens or hundreds of instructions at the machine level. As a result, more programming is now done in high-level languages. Examples of high-level languages are C++, Java, Python, etc. II. Procedural Programing (P1):
Procedural programming is a programming paradigm that is built around the idea that programs are sequences of instructions to be executed. They focus on breaking down programs into named sets of instructions called procedures, which are analogous to functions. A procedure can store local data that is not accessible from outside the procedure's scope and can also access and modify global data variables. This makes the procedure more versatile and efficient. In this case, the functions take precedence over the data. The program in the programming procedural language consists of a series of instructions, each of which requires the computer to perform a certain task, such as reading the user input, performing the necessary calculations, and presenting the results. When the size of the program increases, it is divided into smaller components called procedures or functions. Several functions need to be written to accomplish this task.
Since the same function is generated from many locations, these functions prevent duplication of the code. Only medium size programs are acceptable for this method. There are two types of data in procedural programming: local and global. Local data are data that are contained within a function, and global data are data that are not included in any function. The only function in which local data are identified has access to them. As a result, each function has access to both local and global data. Other functions cannot access local data from one function. If two or more functions require access to the same data, they should be global. On the other hand, global data can be inadvertently changed by another programmer. The division of data and functions is not a good model for real situations. As a result, procedural programming cannot properly reproduce the real system. Some programming languages in which procedural programming can be implemented include COBOL, FORTRAN, C, and Pascal.
III. CHARACTERISTICS OF PROCEDURAL PROGRAMMING (M1):
A predefined function is usually a statement identified by name. Typically, predefined functions are built into higher-level programming languages, but they are derived from a library or registry, not from a program. One example of a predefined function is "charAt()" which looks up the position of a character in a string.
Local variables are variables that are declared in the method's main structure and are restricted to the specified local scope. A local variable can only be used in the method in which it is defined, and if used outside the defined method, the code will not work.
Global variables are variables declared outside of every other function defined in the code. Therefore, unlike local variables, global variables can be used in all functions.
Modularity is when two different systems have two different tasks at hand but combine to complete a larger task first. Then, the tasks of each group of systems will finish one by one until all the tasks are completed.
Parameter passing is a mechanism for passing parameters to functions, subroutines, or procedures. Parameter passing can be done by pass-to-value, pass-to-reference, pass-to-result, pass-to-value-results, and pass-to-name.
B. ANALYZE THE SITUATION: I. Variables and Data Types (P2):
A variable is the name of the memory area where the program can change data. This location is used to store the value of the variable. The value of variable C can be changed in the program. Here, the type must be a valid C data type that contains char, w_char, int, float, double, bool, or any other user-defined object.; The list of variables may consist of one or more identifier names separated by commas. Some valid statements are shown here. The line int i, j, k; declares and defines the variables i, j, and k; which instructs the compiler to create variables called i, j, and k of type int. Variables can be initialized (setting an initial value) in their declaration. The initializer consists of an equals sign followed by a constant expression as follows:
A data type in C programming is a set of values and deterministic actions on those values. C provides various types of data types that allow the programmer to choose the appropriate type for a variable to set its value. A data type in a programming language is a collection of data with fixed meanings and characteristics. Some of them are integers, floats, characters, etc. Often, programming languages specify range values for a given data type. The program uses a total of seven main variables. Includes three floating-point variables and three integer variables. The following table contains information about these variables, such as their names and data types.
II. Conditional Statement (P2):
This is the most important tool in the selection process. Used to execute a single or group statement when the condition is true. If the condition is false, the statement is skipped and the program executes the first statement after the if selection structure to continue. The program uses the if statement structure to find the student with the highest grade function and the student with the lowest grade function. First, use a for loop to accept the Sgrade input from the array. The program begins comparing the inputs of the array one by one. If the value is high, Maxgrade will be assigned and the program will continue to run (Sgrade +1) times. The final value of Maxgrade is the highest grade. First, use a for loop to accept Sgrade input from the array. The program begins comparing the inputs of the array one by one. If the value is small, Mingrade will be assigned and the program will continue to run (Sgrade +1) times. The final value of Mingrade is the lowest grade.
In C, the switch statement compares the value of a variable to some scenarios. When a case match is found, a block of statements related to that particular case is executed. Each case in the switch block has a unique name or number called an identifier. The user's value is compared to all cases in the switch block until a match is found. The value of the variable or expression in parentheses is compared to the value provided by the switch statement on each instance. If a match is found, the statement following the case is executed. If no match is found, the default statement is used. You must place a keyword break at the end of each case to exit the switch immediately after the statement is executed. In this scenario, the programmer defines an integer variable named n. There, the n is considered only once and compared to the value of the case. If a block of statements follows a case that has a matching value, the statements within that block will be executed. case 1 Input ID and grade of student
Unlike for and while loops, which verify the loop condition at the top, the do-while loop in C programming checks it at the bottom. A do-while loop is similar to a while loop, except it guarantees that it will be executed at least once. Two statement actions are available in the program: one for input variables and the other for scanning variable values. When the do-while command is executed, it begins processing the Sgrade values at the end. The loop condition is then used; if true, the loop will return to the start and the loop's body will be run once more. This procedure repeats itself until the condition no longer exists. The do-while loop is responsible for verifying the state of variables as they are typed in.
In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. The syntax of a while loop in C programming language is Here, the statement can be a single statement or a block of statements. Condition is any expression and true is a non-zero value. The loop will keep repeating as long as the condition is true. If the condition is false, program control is passed to the line immediately following the loop.