Docsity

Assignment 1 PROG102 Pass, Assignments of Information Technology

Toggle sidebar
bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Prog102: Procedural Programming
Submission date
26/10/2022
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
NGuyễn Văn Quang
Student ID
GCH211372
Class
GCH1105
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
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Assignment 1 PROG102 Pass and more Assignments Information Technology 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 26/10/2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name NGuyễn Văn Quang Student ID GCH Class GCH1105 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 1

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature: Contents A. Introduction 6 I. Programing language 6

  1. Definition 6
  2. Types of programming language 7 a. Low-level programming language 7 b. High-level programming language 9 II. Procedural Programing (P1) 10
  3. Definition 10
  4. Advantages 11
  5. Disadvantages 12
  • III. Key Features of Procedural Programming (M1)
      1. Predefined functions
      1. Local Variable
      1. Global Variable
      1. Modularity
      1. Parameter Passing
  • B. ANALYZE THE SITUATION
    • I. Variables and Data Types (P2)
        1. Variables
        1. Data Types
    • II. Conditional Statement (P2)
        1. If
        1. Switch-case
    • III. Loop Statement (P2)
        1. For
        1. Do-While
      • How do...while loop works?
        1. While
      • IV. Function of Program (P2) 1. Split function
    • V. Diagram and Flowchart (P3)
        1. Wbs
        1. Use-case diagram
        1. Flowchart
    • VI. EVALUATE THE PROGRAM
  • C. Reference:

2. Types of programming language

a. Low-level programming language

Low-level language is machine-dependent (0s and 1s) programming language. The

processor runs low- level programs directly without the need of a compiler or interpreter,

so the programs written in low-level language can be run very fast. Low-level language is

further divided into two parts -

i. Machine Language

Machine language is a type of low-level programming language. It is also called machine

code or object code. Machine language is easier to read because it is normally displayed

in binary or hexadecimal form (base 16) form. It does not require a translator to convert

the programs because computers directly understand the machine language programs.

The advantage of machine language is that it helps the programmer to execute the

programs faster than the high-level programming language.

ii. Assembly Language Assembly language (ASM) is also a type of low-level programming language that is designed for specific processors. It represents the set of instructions in a symbolic and human-understandable form. It uses an assembler to convert the assembly language to machine language. The advantage of assembly language is that it requires less memory and less execution time to execute a program.

II. Procedural Programing (P1)

1. Definition

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 in 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.

Image of procedural programming

2. Advantages

+ Procedural Programming is excellent for general-purpose programming. + The coded simplicity along with ease of implementation of compilers and interpreters. + A large variety of books and online course material available on tested algorithms, making it easier to learn along the way. + The source code is portable, therefore, it can be used to target a different CPU as well. + 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.

3. 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 it 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 security friendly. + 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.

III. Key Features of Procedural Programming (M1)

1. Predefined functions

Most high level languages will make use of predefined functions. A predefined function is built into the software and does not need to be created by a programmer. Pre-defined functions often exist to carry out common tasks, such as:

  • finding an average number
  • determining the length of a string

2. 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.

3. 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.

4. 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.

5. 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’.

B. ANALYZE THE SITUATION I. Variables and Data Types (P2)

1. Variables

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.

Student has lowest grade Mingrade Float Student's grade is a real number from 0 to 10 Menu option n integer The options are numbered from 1 to 5 Note: n in the flowchart for menu operation is different from ones in others flowchart II. Conditional Statement (P2)

1. If

Conditional Statements in C programming are used to make decisions based on the

conditions. Conditional statements execute sequentially when there is no condition around the statements. If you put some condition for a block of statements, the execution flow may change based on the result evaluated by the condition. This process is called decision making in ‘C.’ The if statement evaluates the test expression inside the parenthesis ().

**_+ If the test expression is evaluated to true, statements inside the body of if are executed.

  • If the test expression is evaluated to false, statements inside the body of if are not executed._**

*Flowchart:

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. In my report, I will use it to declare different options which users choose to report in the "Menu". It will have 4 options. Case 1 (^) Display information of student Case 2 Search information of student Case 3 Find min grade of student Case 4 (^) Find min grade of student Case 5 Exit III. Loop Statement (P2)

1. For

The for loop in C language is used to iterate the statements or a part of the program several times. It is frequently used to traverse the data structures like the array and linked list..

How for loop work?

1 .Expression 2 is a conditional expression. It checks for a specific condition to be satisfied. If it is not, the loop is terminated.

  1. Expression 2 can have more than one condition. However, the loop will iterate until the last condition becomes false. Other conditions will be treated as statements.
  2. Expression 2 is optional.
  3. Expression 2 can perform the task of expression 1 and expression 3. That is, we can initialize the variable as well as update the loop variable in expression 2 itself.
  4. We can pass zero or non-zero value in expression 2. However, in C, any non-zero value is true, and zero is false by default.

6. Do-While

The do...while loop is similar to the while loop with one important difference. The body of do...while loop is executed at least once. Only then, the test expression is evaluated. The syntax of the (^) do...while loop is:

How do...while loop works?

 The body of^ do...while^ loop is executed once. Only then, the^ testExpression^ is evaluated. 

If testExpression is true , the body of the loop is executed again and testExpression is evaluated once more.

 (^) This process goes on until testExpression becomes false.

 If testExpression is false , the loop ends.