Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assignment 1 Procedural Programming (M), Assignments of Learning processes

The work has been graded Merit.

Typology: Assignments

2020/2021

Uploaded on 08/14/2021

UnderLine07
UnderLine07 🇻🇳

4.7

(66)

16 documents

1 / 26

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
Unit 0: Procedural Programming
Submission date
07/10/2020
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Student Name
Trịnh Minh Đức
Student ID
GCH190602
Class
GCH190602
Assessor name
Lại Mạnh Dũng
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
Duc
Grading grid
P2
P3
M1
D1
Tran Doan Dung
GCH200619
Dzung
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Assignment 1 Procedural Programming (M) and more Assignments Learning processes in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 0 : Procedural Programming

Submission date 07/10/2020 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Trịnh Minh Đức Student ID GCH

Class GCH190602^ Assessor name Lại Mạnh Dũng

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 Duc

Grading grid

P1 P2 P3 M1 M2 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

I. Introduction In assignment, I will perform 3 tasks

Task 1: I will introduce programming, programming languages and the main functions of procedural programming to demonstrate that I have the ability and qualification to be appointed to a small project.

Task 2: Perform an analysis for the scenario mentioned above by doing the following

Side quests:

  • Determine the necessary variables and data types in the program.
  • Identify and describe 2 different option constructs, including the condition (s) for testing; stating why they are needed and where they can be used in a scenario context.
  • Identify and describe any iterative constructs. Divide the program into functions (sub functions) and draw hierarchical diagrams to illustrate your program structure.

Task 3: I need to use a drawing tool to draw design diagrams for my program, including:

  • Use case chart for required actions
  • Flow chart for: menu activity, print ID and score, find maximum score and find the minimum score.
  • Review / review my design, clearly state the pros and cons and need improvement, use features of procedural programming as the basis for discussion

1 Procedural programming

Definition

Procedural programming is the first program a programmer will have to learn.

Essentially, the procedure code is a code that directly instructs a device to complete a task in logical steps. This model uses a linear top-down approach and processes data and procedures as two different entities. Based on the concept of a procedure call, Procedural Programming divides a program into procedures, also known as routines or functions, which simply contain a series of steps to be performed.

Simply, 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.

Procedural programming

The main paradigms of procedural programming

Procedure-oriented programming is a programming method that modularizes functions into procedures. From there, large programs are broken down into smaller programs, each undertaking a task called a procedure or function. Procedural programming favors function over data. Here, a program consists of a series of instructions, and each instruction is one that tells the computer to do something. Examples: Read input from the user, calculate the necessary items, check the output and display the output. As for functions, functions do not let the same code coincide because the same function calls from more than one position error. This technique is only suitable for small to medium size software applications. In procedural programming there are two types of data: local data (accessible to the only function it declares) and global data (global data is data that does not fall within any range of functions. function). However, Global Data is vulnerable to accidental changes by programmers. The data arrangement and its own functionality do a poor job of simulating everything in the real world. That is why the procedural methodology does not accurately and perfectly model the real world system.

2.1.1 Every language has its strengths and weaknesses:

Most programming languages have the same strengths and weaknesses. E.g.:

֍ FORTRAN is good for digital data but not good for organizing large programs and suitable only for small and medium programs.

֍ C ++ is good for powerful objects and has features that are suitable for the user, but it is quite complex and difficult to learn.

֍ PASCAL is good for structured and learned programs, but it's not as flexible and convenient as C ++.

֍ choosing a PL depends on the type of computer used, the type of program and the subject matter of the software programmer.

2.1.2 Procedures and modules Modularity simplifies special programs in large and complex programs.

Inputs are usually numeric forms and the output is given under the return values.

Scoping is another technique that helps keep the procedures of other procedures. Scope potentially prevents procedures from accessing the variables of other procedures or reassigning a simple, independent, and reusable interface.

In addition, it is a convenient means of generating different types of code by different users (a different organization) and it includes programming libraries.

2.1.3 Orders and declarations A procedural programming language is an imperative language.

To give commands that instruct the computer to perform tasks.

Describes how the computer performs and operates the tasks assigned from a command.

Declared programming languages like SQL just explain what to do.

2.2 Characteristics and features of a procedural programming language.

The procedural programming language makes it easy for programmers to efficiently design and build large applications with the help of dividing them into smaller programs, also known as functions.

In addition, most of the functions of a procedural programming language are shared within common data. This helps developers transparently move and guide the system from one function to another.

Especially, to build and develop an effective programming language, we need to do it from the top down, so that we can easily check and correct program errors.

However, procedural programming breaks programs down into data structures, variables and subroutines to help programmers more convenient.

Programming languages allow a developer to program general purpose and provide a greater level of control like portable source code. So it can be said that procedural programming involves using to evaluate and analyze all differentiating areas and provide better solutions to complex programs.

2.2.1: Methods: Methods in a procedural programming language are used to store and store a set of instructions that a procedure is run in is called a method. Also it is used in programming languages with an access designation.

2.2.2 Loop: In the for loop procedural language, while loops and do- while loops are used to run and loop the command lines of the program given by the software designer. used on running casdc code list and instructions.

The loop is used in a programming procedure to run many times to save time. However, we should only use for loop for small loops (a few tens).

While loop is executed after checking for conditions.

Do-While Loop is executes the instruction's code then executes the program.

An example of a pre-defined function is "char At)" (that searches for a function for a character position in a string.

2.2.3.2 Local variable and global variable: A local variable is a variable that has been declared as the key variable. A method’s structure and is restricted to the local area it is given. It can just be the local variable used in the method in which it is specified, and if it were to be used beyond the method defined, the code would be used. They will stop operating. A global variable, on the other hand, is a variable that is declared outside of the some other feature that's specified in the code. Thanks to this, it is possible to use global variables in all functions, unlike a local variable.

Example: Local variable and global variable

2.2.3.3 Passing parameters: In comparison, the passing parameters include the vector values that are transmitted. Via the software to the process, all the way. Parameter Passing is a method that is used for passing functions, subroutines, or process parameters. "Passing of parameters can be achieved via" passing by value', 'pass by reference', 'pass by result', 'pass by result-value' and 'pass by name.

Example about passing parameters

2.3: Procedural programming language and object-oriented programming language:

Procedural programming language and Object-oriented programming language

2.3.1. Data Type What is Data Type?

Programming uses a number of different data types. A data type determines what type of value an object can have and what operations can be performed Basic Data Types

2.3.2. Type int Stores numeric data Cannot store other type e.g., “Alan” or “abc” Declaration: int num; Size (Depends on the Operating System) Normally 32 bits (4 bytes) Integers in the range: -32768 to 32767 Examples: 12322, 0, -

2.3.3. Type float Stores values containing decimal places

Cannot store other type e.g., “Alan” or “abc” Precision of up to 6 digits Declaration: float num; Size (Depends on the Operating System) Normally 32 bits (4 bytes) Examples: 12.1, 14.5, 15

2.3.4. Type double Stores values containing decimal places Cannot store other type e.g., “Alan” or “abc” Precision of up to 6 digits Declaration: float num; Size (Depends on the Operating System) Normally 32 bits (4 bytes) Examples: 12.1, 14.5, 15.

2.3.5. Type char Stores single character information Cannot store other type e.g., “Alan” or “abc” Declaration: char c; Size (Depends on the Operating System) Normally 8 bits (1 byte) Examples: ‘a’, ‘b’, ‘$’, ‘%’, ‘1’, ‘2’.

2.3.6. Type void Stores nothing

This is used to indicate the compiler that there is nothing to expect.

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. As required, we need to enter student number, class and student score. We need 2 arrays to do that. The first array is the array of integers and the second array is the array of real numbers for the class to declare. Call the first and last name variables, the class and the student ID by the char function to declare the variables.

It is important that we use the library or use <stdio.h> to develop this software.

This is a very important first step in laying the foundation for each program when the programmer wants to create the program. Next to the data declaration, we need to use the char function to declare first and last name, class and student code. The reason for choosing this function is because it is simple to learn, easy to apply when we need to declare variable characters and numbers.

Pay attention to the topic, we only need to enter student information from one class, so we do not need to use too many functions to declare the class anymore, only one is enough to use the declaration of other variables such as scores and the student with the lowest scores and the student with the highest scores. We need to construct a variable to insert a student's name into the program and print out the chart. Containing a 2-dimensional char array: full name char [50] [100]. A limit of 50 makes this list names for pupils, each containing up to 100 characters. Single character char type vector no other kind of information may be stored, e.g., 'Alan' or 'ABC', size (Operating System Depends): 8 bits (1 byte) as a precedent.

We have the preference of I size variables added to the int function to set the menu of options and the number of students to handle. Class int holds binary data that may not contain other types, e.g. "Alan" or "abc" size (depending on the operating system): in the range: -32768 to 32767, typically 32 bits (4 bytes) integers. Also, we need to list the choice and size elements in order to be able to determine the size and the choice to be put into the program. Avoid functions that have not been declared, resulting in the program not running. For the request that the thread takes, we should choose the do-while loop: First, the software will always run the body of the loop, the body is still expelled at least once, and the condition is checked at the end of the cycle. The loop continues if it is real, if it is wrong, the loop will stop. It's important to terminate the do-while declaration.

We do not use for- while loops here because this loop only checks in the first loop. Also, should not use while loop because this loop can only be used once.

Print out the menu screen and the option that the topic is going to include such as entering student information and the second one is from the program one that filters out the students with the highest scores and the students with the lowest scores. In addition, you can increase the aesthetics of your display by using a string of characters ("**********"). Switch ... case declaration : It is possible to use if-else-if sentences instead. Used in cases where several attributes arise from the expression being judged.