assignment 1: procedural programming complete version, Assignments of Mathematics for Computing

assignment 1: procedural programming complete version

Typology: Assignments

2020/2021

Uploaded on 10/23/2021

minh-huy-huynh
minh-huy-huynh 🇻🇳

4.7

(58)

39 documents

1 / 39

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 23/10/2021
Date Received 1st
submission
Re-submission Date Date Received 2nd
submission
Student Name Huynh Minh Huy Student ID GCD210173
Class GCD1001 Assessor name Phan Thanh Tra
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 Huy
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
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download assignment 1: procedural programming complete version and more Assignments Mathematics for Computing 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 23/10/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Huynh Minh Huy Student ID GCD Class GCD1001 Assessor name Phan Thanh Tra 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 Huy Grading grid P1 P2 P3 M1 M2 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

TABLE OF CONTENTS

CHAPTER 2: IDENTIFICATION OF THE PROGRAM DATA, FILE AND UNIT STRUCTURE.

  • TABLE OF TABLES.....................................................................................................................................................
  • CHAPTER 1: INTRODUCTION TO PROCEDURAL PROGRAMMING..........................................
      1. An overview of programming languagues...........................................................................................................
      • 1.1. Programming Language................................................................................................................................
      • 1.2. What is Language?........................................................................................................................................
      • 1.3. What is a Programming Language?...............................................................................................................
      • 1.4. Types of Programming Language?................................................................................................................
        • a. Low – level Programming Language.............................................................................................................
        • b. High – level programming language.............................................................................................................
        • c. Middle – level programming language.......................................................................................................
      1. Introduction to C Language................................................................................................................................
      1. Procedural Programming...................................................................................................................................
      1. Discuss on characteristics and features of procedural programming................................................................
      • 4.1. Features of Procedural Programming.........................................................................................................
      • 4.2. Characteristics of procedural programming................................................................................................
      1. Describe the problem that the situation presents.............................................................................................
      1. Analysis of variables and data types required in the program...........................................................................
      • 1.1. What is Variable?........................................................................................................................................
      • 1.2. What is Data Type?.....................................................................................................................................
      1. Conditional Statements.....................................................................................................................................
      • 2.1 What is a Contional Statement in C?...........................................................................................................
        • a. “if” statement function..............................................................................................................................
        • b. “switch case” statement function..............................................................................................................
        • c. “if... else” statement function....................................................................................................................
      1. Loop Statements................................................................................................................................................
      • 3.1 What is Loop Statement in C?......................................................................................................................
        • a. For loop......................................................................................................................................................
        • b. Do - while Loop..........................................................................................................................................
        • c. While Loop.................................................................................................................................................
      1. Functions...........................................................................................................................................................
  • CHAPTER 3: DESIGN..............................................................................................................................
      1. What is a Hierarchical Chart?.............................................................................................................................
      1. What is a Use Case Diagram?.............................................................................................................................
      1. What is a Flowchart?..........................................................................................................................................
      • 3.1. Flowchart diagram for menu.......................................................................................................................
      • 3.2. Option input flowchart................................................................................................................................
      • 3.3. Option display flowchart.............................................................................................................................
      • 3.4. Find highest grades.....................................................................................................................................
      • 3.5. Find lowest grades......................................................................................................................................
  • CHAPTER 4: EVALUATION...................................................................................................................
      1. Review and evaluate the design........................................................................................................................
    • References.............................................................................................................................................................
  • Figure 1: Programming Languages............................................................................................................................... TABLE OF FIGURES
  • Figure 2: C....................................................................................................................................................................
  • Figure 3: FORTRAN.......................................................................................................................................................
  • Figure 4: PASCAL..........................................................................................................................................................
  • Figure 5: C++................................................................................................................................................................
  • Figure 6: C#..................................................................................................................................................................
  • Figure 7: PYTHON.......................................................................................................................................................
  • Figure 8: Structure of C program (GeeksforGeeks, 2021)..........................................................................................
  • Figure 9: Advantages and Disadvantages of C programming.....................................................................................
  • Figure 10: Procedural Programming..........................................................................................................................
  • Figure 11: Predefined Function..................................................................................................................................
  • Figure 12: Parameter Passing....................................................................................................................................
  • Figure 13: If statement flowchart..............................................................................................................................
  • Figure 14: If statement in program............................................................................................................................
  • Figure 15: Switch case statement flowchart..............................................................................................................
  • Figure 16: Switch case statement in program............................................................................................................
  • Figure 17: If…else statement flowchart.....................................................................................................................
  • Figure 18: If…else statement in program...................................................................................................................
  • Figure 19: For Loop Flowchart...................................................................................................................................
  • Figure 20: For Loop in program..................................................................................................................................
  • Figure 21: Do – while Loop flowchart........................................................................................................................
  • Figure 22: Do – while Loop in program......................................................................................................................
  • Figure 23: While Loop flowchart................................................................................................................................
  • Figure 24: While Loop in program.............................................................................................................................
  • Figure 25: Hierarchical chart......................................................................................................................................
  • Figure 26: Use Case Diagram.....................................................................................................................................
  • Figure 27: Flowchart diagram for menu....................................................................................................................
  • Figure 28: Option input..............................................................................................................................................
  • Figure 29: Option display...........................................................................................................................................
  • Figure 30: Finding highest grade................................................................................................................................
  • Figure 31: Finding lowest grade.................................................................................................................................
  • Table 1: Data Types.................................................................................................................................................... TABLE OF TABLES
  • Table 2: Variable required in the program.................................................................................................................

CHAPTER 1: INTRODUCTION TO PROCEDURAL PROGRAMMING.

1. An overview of programming languagues. 1.1. Programming Language. As we all know, in order to communicate with another person, we must use a specific language; similarly, in order to communicate with computers, programmers must use a language known as a programming language. 1.2. What is Language? Language is a form of communication in which people exchange ideas and opinions. For instance, if we want to teach someone, we must use a language that both communicators understand. 1.3. What is a Programming Language? A programming language is a computer language that is used to communicate with computers by programmers (developers). It is a set of instructions written in any language (C, C++, Java, Python) to accomplish a specific task. A programming language is primarily used to create desktop applications, websites, and mobile apps.

b. High – level programming language. High – level programming language (HLL) is designed for developing user – friendly software programs and websites. This programming language requires a compiler or interpreter to translate the program into machine language (execute the program). The main advantage of a high – level language is that it is easy to read, write and maintain. High – level programming language includes Python, Java, JavaScript, PHP, C#. C++, Objective C, Cobol, Perl, Pascal, LISP, FORTRAN and Swift programming language. A high – level language is further divided into three parts:  Procedural Oriented Programming Language: Procedural Oriented Programming (POP) language is derived from structured programming and based upon the procedure call concept. It divides a program into small procedures called routines or functions. Procedural Oriented programming language is used by a software programmer to create a program that can be accomplished by using a program editor like IDE, Adobe, Dreamweaver or Microsoft Visual Studio. Example: C, FORTRAN, Pascal, etc. Figure 2 : C

Object – Oriented Programming Language: Object – Oriented Programming (OOP) language is based upon the objects. In this programming language, programs are divided into small parts called objects. It is used to implement real – wolrd entities like inheritance, polymorphism, abstraction, etc in the program to makes the program resusable, efficient and easy – to – use. The main advantage of object – oriented programming is that OOP is faster and easier to execute, maintain, modify, as well as debug. Example: C++, C#, Python, etc. Figure 3 : FORTRAN Figure 4 : PASCAL Figure 5 : C++ Figure 6 : C#

2. Introduction to C Language. The C programming language is a procedural programming language. Dennis Ritchie created it for the first time in 1972. It was created primarily as a system programming language for developing operating systems. Low-level memory access, a minimal set of keywords, and a clean style are all properties of the C language that make it suited for system programming, such as operating system or compiler development. Many following languages have directly or indirectly inherited syntax and features from C. The C language is the foundation for several languages, including Java, PHP, JavaScript, and many others. C++ is a near-superset of the C language (just a few programs will compile in C, but not in C++) (GeeksforGeeks, 2021).

C is one of the oldest programming languages that cannot be replaced since it is at the heart of every machine. As a result, there are some benefits and drawbacks to using this programming language. Figure 8 : Structure of C program (GeeksforGeeks, 2021) Figure 9 : Advantages and Disadvantages of C programming.

Procedural Programming has its own set of advantages and disadvantages, some of which are listed here.  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.  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 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 much security friendly.

4. Discuss on characteristics and features of procedural programming. 4.1. Features of Procedural Programming. - Predefined functions: A predefined function is a type of instruction that has a name attached to it. Predefined functions are usually included in higher-level programming languages, although they are obtained from a library or registry rather than a program. "printf(….)" is an example of a predefined function.

4.2. Characteristics of procedural programming.  A large program is broken down into small manageable procedures or functions. This minimizes code duplication, making the code more readable and maintainable.  Different functions can share data via global variables. Because functions are entirely separated, we must declare data in the higher scope if we wish to share it.  Functions can change global data. Because global data is passed from function to function, global data in function chains may be changed throughout the transformation.  Top-down methodology. Procedural programming employs a top-down approach, with workflow moving from top to bottom.

5. Describe the problem that the situation presents. A math teacher wishes to keep track of his or her students' grades. To manage student grades and IDs, we must first enter them into the system so that it can keep track of data and continue to function. Without initial data, the application will not be able to function. After that, he must print all of the students' IDs as well as their grades. Because there is a huge quantity of data, displaying it all and finding the highest and lowest grades will cause the statements to be executed repeatedly from the beginning of the array to the end of the array, we must use a loop with the correct condition to allow the program to do it. Furthermore, the program's requirements include a large number of options to choose from, thus we should use the function to easily manage and update them. Finally, the highest and lowest grade must be printed. Figure 12 : Parameter Passing

CHAPTER 2: IDENTIFICATION OF THE PROGRAM DATA, FILE AND UNIT

STRUCTURE.

1. Analysis of variables and data types required in the program. 1.1. What is Variable? Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. Variables can be thought of as information-holding containers. They exist just to categorize and store data in memory. This data can then be used to other parts of your program.