Prog102: Procedural Programming (M), Assignments of Information Technology

The document for person who want to grade merit

Typology: Assignments

2020/2021
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 11/19/2021

le-duy
le-duy 🇻🇳

4.9

(15)

9 documents

1 / 34

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
20/10/2021
Date Received 1st
submission
25/10/2021
Re-submission Date
Date Received 2nd
submission
Student Name
Student ID
Class
GCD0905
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
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
Discount

On special offer

Partial preview of the text

Download Prog102: Procedural Programming (M) 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 Prog 102 : Procedural Programming Submission date 20 /10/2021 Date Received 1st submission 25/10/ Re-submission Date Date Received 2nd submission Student Name Student ID Class GCD0905 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:

  • P1. Introduction to Procedural Programming: __________________________
      1. Introduction to Computer Programming Languages:__________________________
      • a. Definition: _________________________________________________________
      • b. Classification of Programming Languages: _______________________________
      • c. Some Computer Programming Languages: _______________________________
      1. C language: _________________________________________________________
      • a. Definition: _________________________________________________________
      • b. Advantage and disadvantage C language: ________________________________
      1. Definition of Procedural Programming: ___________________________________
  • P2. Characteristics of Procedural Programming: _______________________
      1. Function: __________________________________________________________
      1. Local Variable: _____________________________________________________
      • a. Definition: ________________________________________________________
      • b. Advantages and disadvantages of using Local Variable: ____________________
      1. Global Variable: ____________________________________________________
      • a. Definition: ________________________________________________________
      • b. Advantages and disadvantages of global variable: _________________________
      1. Modularity _________________________________________________________
      1. Parameter Passing: ___________________________________________________
      • a. Pass by value: _____________________________________________________
      • b. Pass by reference: __________________________________________________
      • c. Pass by the name: __________________________________________________
      • d. Pass by value-result: ________________________________________________
      1. Program Structure: ___________________________________________________
      • a. Function Declaration________________________________________________
      • b. Procedural Program Organization: _____________________________________
      • c. Program Organization: ______________________________________________
  • P3. Analyze the situation: _________________________________________
      1. Variables and Data Types: _____________________________________________
      • a. Variable: _________________________________________________________
      • b. Data Types:_______________________________________________________
      1. Identify the variables and data types required in the program: _________________
      1. Conditional statements: _______________________________________________
      • a. “Switch case” statement function: _____________________________________
      • b. “If” statement function: _____________________________________________
      1. Loop statements: ____________________________________________________
      • a. “For” loop syntax:__________________________________________________
      • b. “Do…while” and “while” statement: ___________________________________
      1. Function: __________________________________________________________
      • a. Theory: __________________________________________________________
      • b. In the program: ____________________________________________________
    • Hierarchy diagram _____________________________________________________
  • P4. Design: ____________________________________________________
      1. Use case diagram for actions required ____________________________________
      1. Flowcharts: ________________________________________________________
  • P5. References _________________________________________________
  • Tables1 - Table of Variables ______________________________________ Table of Tables
    • Figures:1 - Computer Programming Languages _______________________________ Table of Figures
    • Figures:2 - High & Low language __________________________________________
    • Figures:3 - C Language __________________________________________________
    • Figures:4 - C++ language ________________________________________________
    • Figures:5 - C# language __________________________________________________
    • Figures:6 - Advantages and disadvantages of C language ________________________
    • Figures:7 - Procedural Programming _______________________________________
    • Figures:8 - Some of the predefined functions in stdio.h header file _______________
    • Figures:9 - Some of the predefined functions in stdio.h header file _______________
  • Figures:10 - Example of Function Declaration _______________________________
  • Figures:11 - Example of Program Organization ______________________________
  • Figures:12 - Code example of “Switch case” ________________________________
  • Figures:13 - Code example of “if” _________________________________________
  • Figures:14 - Code example of “For” _______________________________________
  • Figures:15 - Code example of “Do…While” _________________________________
  • Figures:16 - Code example of “While” _____________________________________
  • Diagram1 - Hierarchy Diagram ___________________________________________ Tables of diagrams
  • Diagram1 - Use Case Diagram ___________________________________________
  • Diagram1 - Menu Flowchart _____________________________________________
  • Diagram2 - Enter student’s information Flowchart ____________________________
  • Diagram3 - Display student’s information Flowchart __________________________
  • Diagram4 - Find highest grade Flowchart ___________________________________
  • Diagram5 - Find lowest grade Flowchart ___________________________________

- Low-level languages: It is the programming language with non-powerful abstraction. The programmers need to study carefully about computer design due to deep understanding of computer layout that for composing the program for such a computer. Not like High-level Languages, the Low- level Languages programs are only for one main computer. As a result, Low-level Languages is less popular than High-level Languages. Examples: Assembly Language, Machine Language,… Figures:2 - High & Low language c. Some Computer Programming Languages:

Figures:3 - C Language Figures:4 - C++ language Figures:5 - C# language

  1. C language: a. Definition: C is a high-level, general-purpose programming language that is ideal for developing firmware and portable applications. Dennis Ritchie developed C for the Unix Operating System at Bell Labs in the early 1970s with the goal of writing system software. C is one of the most widely used programming languages, with compilers for practically every computer platform. It has influenced a number of other languages, the most notable of which is C++.

Figures:7 - Procedural Programming P2. Characteristics of Procedural Programming:

  1. Function: In a program, a function is a procedure that may be invoked by its name. Built-in functions refer to predefined functions. They are a collection of subroutines that perform specialized functions. These functions are often included in high-level programming languages like Python and C++, but they may also be imported into the programming language via registries or libraries. Figures:8 - Some of the predefined functions in stdio.h header file User-defined functions, on the other hand, are functions that are generated by the user and must be loaded through a program, meaning they can only be found in that application. Concat(), for example, is a pre-defined function that combines the text of two strings into a single string.a new string was added sqrt(), for example, returns the square root of any number.Because it is built-in to Python, the sqrt() function is a predefined function.They're useful because they spare the user from having to write a long line of code for a procedure and allow them to focus on other things.Allow them to utilize a function rather than a command. Furthermore, built-in functions do not necessitate the installation of any other software.

Figures:9 - Some of the predefined functions in stdio.h header file

  1. Local Variable: a. Definition: In computer languages, variables are storage spaces with specific names. User-defined values can be assigned to them. They are used to refer to the stored value of a program. Local variables, also called lexical variables, are variables that are defined within a method and can only be used or referred within that method. As a result, their application is confined to that technique, and they cannot be used in other situations. If there are any local variables created in this function, other methods in the program will be oblivious of them. If a local variable is used in another function, the software will throw an error. b. Advantages and disadvantages of using Local Variable: Advantages:
  • The use of local variables ensures that variable values are retained while the task is being carried out.
  • When several tasks change the same variable at the same time, the result could be surprising. Declaring it as a local variable, on the other hand, solves this problem because each task creates its own local variable instance.
  • You can give local variables the same name in different functions because they are only recognized by the function in which they are defined.
  • Local variables are erased when a function is completed to save memory space.

outcomes.

  • If global variables are no longer used as a result of code restructuring, you'll need to update all of the modules that use them.
    1. Modularity Modularity refers to the use or use of modules, or pieces or components. It implies breaking down a huge problem into tiny chunks so that it may be solved quickly. It entails breaking down the program's functionality into smaller, independent components, each of which may do the job for which it was created. The work may be split down into smaller executable parts that can be readily turned into computer code thanks to the modular design. As a result, it is the breaking down of a program into smaller chunks that are easier to comprehend, alter, and administer. Modular programming in structural programming refers to the use of structured flow in low-level code. There are several advantages to programming in a modular fashion. The program is easier to work on, which is a significant benefit. It also allows you to invoke a piece of code many times. A single module can also be run independently of the rest of the program because it is a standalone component. The idea of modularity in procedural programming indicates that a big program is divided into smaller components, each of which performs a single task. These modules or components complete duties one by one before delivering the ultimate product.
    2. Parameter Passing: Parameter passing is a programming language feature that allows parameters to be given to procedures or functions. The term parameter should not be confused with the term argument. The argument is the value that is provided to the function and is processed by it, whereas the parameter is the value that is specified in the function when it is declared. Multiple ways can be used to pass parameters to a function. The four parameter passing techniques are listed and discussed below: a. Pass by value: In-mode semantics are used in pass by value mode. Any changes to the perimeter are not sent to the caller while using this approach. Changes to the parameter are solely reflected in the separate storage location, and they have no effect on where the function is invoked.

b. Pass by reference: In/out-mode semantics are used in this technique. Changes to the parameter are communicated back to the location where the function is called using this technique. c. Pass by the name: The name of the variable is provided in this form of parameter passing, allowing it to be accessed and modified. d. Pass by value-result: This technique is a mix of pass by value and pass by result and leverages in/out-mode semantics. Before the control transfers to the caller, the value of the formal parameter is returned to the real parameter using this technique.

  1. Program Structure: a. Function Declaration Figures:10 - Example of Function Declaration b. Procedural Program Organization: Subroutines (functions or procedures) are used to write procedural software code. Procedures can be specified either in the main program code or in a separate header file distinct from the main program code. The subroutines can also be specified in a separate file that can be included in the main program as a header file to improve the readability of

The line int i, j, k; declares and defines the variables i, j, and k; which instruct the compiler to create variables named i, j and k of type int. Variables can be initialized (assigned an initial value) in their declaration. The initializer consists of an equal sign followed by a constant expression as follows: b. Data Types: A data-type in C programming is a set of values and is determined to act on those values. C provides various types of data-types which allow the programmer to select the appropriate type for the variable to set its value. The data-type in a programming language is the collection of data with values having fixed meaning as well as characteristics. Some of them are an integer, floating point, character, etc. Usually, programming languages specify the range values for given data-type.

The program employs a total of seven main variables. Three float variable, and three int variables are included. The table below contains information on these variables, such as their names and data types.

  1. Identify the variables and data types required in the program: Variable’s name Data type Explanation Grade[50] float - It is responsible for the pupils' grades. - I decided using float because it allows me to use real numbers. IDs[50] int - It displays student identification.
  • I chose int since it only contains integers. Max/min float - I chose int since it only contains integers.
  • It encompasses both integers and real values, I chose float. Max ID, Min ID int - It displays the ID of the student with the highest or lowest grade. - I chose int since it only contains integers. Choice int - It keeps track of the options that the user selects.
  • I chose int since it only contains integers. I, j int - They are utilized in loop functions and in array functions as numerical numbers.
  • I chose int since it only contains integers n int - It lists the total number of students enrolled.
  • I chose int since it only contains integers
  • A for loop is a control flow statement that is used to repeatedly execute a group of statements as long as a condition is met. This type of statement is also known as an iterative statement. As a result, a for loop is an iterative statement.
  • This function allows the software to do the same thing again and over again under particular conditions. The program will continue if condition is true, and it will only halt if condition is false.
  • This tool aids me in determining the greatest or lowest grade in my program. As a result, I may compare "max" and "min" to every element in memory. Figures:14 - Code example of “For”
  • In this example, I compare "min" with each element grade in the array, and after this function, I receive the lowest grade value, which is known as min. b. “Do…while” and “while” statement:
  • Iteration structures are divided into two categories. Their work, however, is founded on the same principle: a series of operations with a single condition. They will cause the software to repeat the activities until the condition returns false. However, the order in which they take steps differs.
  • To be more specific, the software will perform the activities first before testing the condition in the "Do... while" phrase. If not, the condition will be tested first, and then the actions in the "While" statement will be performed.
  • If the program is given the correct condition in the first step, both the statements "Do... While" and "While" will return the same value or result. However, if we offer the erroneous condition in the first implementation, we will plainly observe the difference between these two. With a "While" statement, the program does nothing and terminates instantly. However, in "Do... while," the program performs the supplied actions once and then exits the iteration constructs.
  • Overall, I can encourage my program to collect the proper type of data from users and perform a number of behaviors until I get the right information using these two statements. Figures:15 - Code example of “Do…While”
  • The “Do... while” statement persuades users to enter the number of pupils in this example. If a character is entered, the condition is true (Checknum(n) is a function that verifies input as an integer, and this condition checks input as not an integer), and the statement is still executed. It indicates that customers will have to enter data repeatedly until it is an integer. Figures:16 - Code example of “While”
  • The number of pupils in this scenario is n. The application will print each student one at a time to the screen. If the number of students is 0, the iteration constructs will be exited, and the function will be terminated (n is inputted from user)
  1. Function: a. Theory: A function is a collection of linked statements that accomplishes a specified goal. Functions aid in the division of our software into smaller, modular parts. Functions help our program become more structured and controllable as it grows in size. It also eliminates duplication and makes the code reusable. Every C program contains at least one function, main(), and even the simplest programs can specify more functions. The name, return type,