Procedural Programming Assignment for BTEC Level 5 HND in Computing: Prog102, Lecture notes of Technical Writing

A front sheet for an assignment in Procedural Programming for the BTEC Level 5 HND in Computing. The assignment requires students to design and implement a grade management program for a class, using procedural programming concepts such as variables, selection structures, iteration structures, functions, and parameter passing. The document also includes an introduction to procedural programming and its principles.

Typology: Lecture notes

2021/2022

Uploaded on 10/09/2022

tran-quang-anh-thuan-fgw-hcm
tran-quang-anh-thuan-fgw-hcm 🇻🇳

3 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Prog102: Procedural Programming
Submission date
Date Received 1st
submission
Re-submission Date Date Received 2nd
submission
Student Name Student ID
Class Assessor name
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 D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Procedural Programming Assignment for BTEC Level 5 HND in Computing: Prog102 and more Lecture notes Technical Writing in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Student ID Class Assessor name 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: Table of Contents 1 Introduction (P1) ................................................................................................................................................................... ...

Scenario ............................................................................................................................................................ ......... 4 2 PRINCIPLES OF PROCEDURAL PROGRAMMING. .......................................................................................................................................... ............................ 2.1 COMPUTERS & PROGRAMS ................................................................................................................................................... .................. 4 2.1.1 Definition ............................................................................................................................................ 2.1.2 What is coding and how does it work? ...............................................................................................

3.2.1 If-Else Statement ................................................................................................................................. 3.2.3 Switch-case………………………………………………………………………………………….. 3.2.3 Enter the number of students and create a list ................................................................................... 3.3 Hierarchical diagram of the program .................................................................................................. 3.3 Design a procedural programming solution for a given problem .......................................................... 3.3.1 Use-Case Diagram .............................................................................................................................. 3.3.2 Flow chart diagrams ...........................................................................................................................

1 Introduction (P1)

1.1 Scenario A math teacher wants a grade management program for a class. He asks you to help him write a small app to do that. He needs to enter the student's number, the student's score, and store this information in two separate arrays (the integer array for the student number and the real array for the score). Then, he needs to print all the student cards along with their grades. Finally, he needs to know which student has the highest and lowest scores. Your program should have a menu based on the options above. When an option is done, the program will go back to the main menu so he can choose another option. There will be an option to exit the program.

2 PRINCIPLES OF PROCEDURAL PROGRAMMING.

2.1 COMPUTERS & PROGRAMS

2.1.1 Definition A computer is a machine that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. Modern computers have the ability to follow generalized sets of operations, called programs. These programs enable computers to perform an extremely wide range of tasks. A "complete" computer including the hardware, the operating

system (main software), and peripheral equipment required and used for "full" operation can be referred to as a computer system. Today’s computers are electronic devices that accept data (input), process that data, produce output, and store (storage) the results. Figure 1: Definition Computer A computer program is a collection of data and instructions that can be executed by a computer to perform a specific task. A computer program is usually written by a computer programmer in a programming language. From the program in its human-readable form of source code, a compiler or assembler can derive machine code—a form consisting of instructions that the computer can directly execute. Alternatively, a computer program may be executed with the aid of an interpreter. Computer programs may be categorized along functional lines, such as application software and system software.

programmers to translate important commands into binary code. (Computer Science Degree Hub,

Program development process:

  • Step 1: Analyze
  • Step 2: Draw the algorithms that will be used in the program
  • Step 3: Start writing code
  • Step 4: Check and correct errors or the coders called Test and Debug.
  • Step 5: Installation and Maintenance 2.2 INTRODUCTION TO PROCEDURAL PROGRAMMING Procedural programming may be the first programming paradigm that a new developer will learn. Procedural programming is a programming method that assists in splitting functions into several procedures. In procedural programming, a large program is divided into smaller manageable parts called procedures or functions. Here, priority is given to functions over data. In a procedural programming language, a program basically consists of a series of instructions, each of which tells the computer to do things like reading input from the user, perform the necessary calculations, and display output. 2.2.1 Simple Program As we learn to code, we will learn the basics of how to output "Hello World!" to the screen. ➢ To do this, we start with the simplest "printf" command that prints the words "Hello World!" Figure 4: Simple program

2.2.2 Variable Variables are containers for storing data values. In C there are 5 basic data types. All other data types are based on one of these. The 5 data types are: ➢ Int: is an integer, it basically denotes the natural size of integers. ➢ Float and double: are used for floating point numbers. The float (real number) type takes up 4 bytes and can have up to 6 part numbers after the decimal point, while double occupies 8 bytes and can have up to 10 decimal places. ➢ Char : occupies 1 byte and can store a single character. ➢ Void: is typically used to declare a function that does not return a value. This will be discussed more clearly in the function section. The memory capacity and range of these types vary with each processor type and the installation of C compilers. Figure 5: Variable 2.2.3 Three constructions ➢ Sequence construct A sequence construct tells the CPU (processor) which statement is to be executed next. By default, in popular languages, this is the statement following the current statement or first statement in the program. In other words, this is the very basic construct of writing a program. You just write line by line what you have in mind (of-course related to programming).

Figure 7: Selection Structure ➢ Iteration Structure A repetition construct causes a group of one or more program statements to be invoked repeatedly until some end condition is met. For example, let's say we have 20 working days in a month and we have to calculate the full month's salary for our employees. In this case, "some of the last conditions met" will refer to whether we repeated the same instruction sequence or repeated 20 times. We also use the term 'loop' rather than reset or repeat. (Mukit, 2018) So the whole process in one visualization below: Figure 8: Iteration Structure 2.2.4 Function

  • Definition: A function is a subroutine that performs a block of work repeatedly while running a program, or uses a block of work to be separated from a specific work block so that the program is less complex. ➢ A function is a piece of program that performs a specified task. ➢ Functions are used to shorten a series of instructions that are executed over and over. ➢ Debugging the program becomes easier when the structure of the program is clear. ➢ A program composed of functions is also easy to maintain, because on-demand modification is limited to each function of the program.

Function definition syntax:

  • myFunction() is the name of the function Figure 9: MyFunction MyFunction has two function type: ➢ Standard Library Functions ➢ User-defined FunctionFunction with no arguments and no return value
  • Function with no arguments and no return value
  • Function has arguments and no return value Figure 11: Function with argument and no return

elements defined in the interface are detectable by other modules. The implementation contains the working code that corresponds to the elements declared in the interface. Modular programming is closely related to structured programming and object-oriented programming, all having the same goal of facilitating construction of large software programs and systems by decomposition into smaller piece. While the historical usage of these terms has been inconsistent, "modular programming" now refers to the high-level decomposition of the code of an entire program into pieces: structured programming to the low-level code use of structured control flow, and object-oriented programming to the data use of objects, a kind of data structure. Figure 14: Modularity

3 DESIGN PROCEDURAL PROGRAMMING SOLUTIONS

3.1 Identify Input, Output 3.1.1 In/Out variables

  • Input variables: Figure 5: Main variable
  • Output variables: ➢ A menu list ➢ The student with the highest score ➢ The student with the lowest score 3.1.2 Main variable -Use to store each student’s information
  • Function struct In the above case, a Student is a structure containing two variables, ids and grades. When structure is declared, no memory is allocated. When a structure variable is created, memory is allocated. 3.1.3 Input student information Figure 15: Input student’s information
  • We use this for containing more a number of students

I use int and float to find the lowest grades Figure 17: Find low grades : Use for determine student number : The if helps us to find the lowest grades 3.1.6 Find max

Figure 18: Find high grades : The if helps us to find the highest grades 3.1.7 Menu selection Figure 19: Menu selection 3.2 The required construction for the Management solution 3.2.1 If-Else Statement ➢ IF-Else Statement(max)

Figure 19: switch-case The purpose of using the switch case is to make a user selection from the menu. Switch case statement is used when trying to check for an integer value. To be optimal for helping teachers manage classes, if the number of conditional expressions to compare is too much, we prefer to use switch case statements because the syntax is clearer.

Making flow chart and diagram

3.3 Hierarchical diagram of the program

3.3 Design a procedural programming solution for a given problem 3.3.1 Use-Case Diagram 3.3.2 Flow chart diagram Flow chart to find highest grades