Procedural Programming: Understanding the Basics and Key Features, Assignments of Computer Science

An introduction to procedural programming, discussing its principles, characteristics, and features. It includes a guide on programming in general with an emphasis on procedural programming, as well as tasks requiring the creation of design diagrams and evaluating the design against procedural programming features.

Typology: Assignments

2021/2022

Uploaded on 06/23/2022

andrew-2709
andrew-2709 🇻🇳

4.8

(20)

33 documents

1 / 66

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Higher Nationals in Computing
Unit 0: Procedural Programming
ASSIGNMENT 1
Learner’s name: Duong Trong Qui
ID: GBS200716
Class: GCS1005A
Subject code: PROG102
Assessor name: PHAN MINH TAM
Assignment due: Assignment submitted:
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
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42

Partial preview of the text

Download Procedural Programming: Understanding the Basics and Key Features and more Assignments Computer Science in PDF only on Docsity!

Higher Nationals in Computing

Unit 0: Procedural Programming

ASSIGNMENT 1

Learner’s name: Duong Trong Qui

ID: GBS

Class: GCS1005A

Subject code: PROG

Assessor name: PHAN MINH TAM

Assignment due: Assignment submitted:

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 0: IT Fundamental & Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Duong Trong Qui Student ID GBS Class GCS1005A Assessor name Phan Minh Tam 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 Qui Grading grid P1 P2 P3 M1 M2 D

ASSIGNMENT 1 BRIEF Unit Number and Title Unit 0: IT Fundamental & Procedural Programming Academic Year 2021 Unit Tutor Assignment Title Assignment 1: Analysis and Design a solution for procedural programming problem Issue Date Submission Date IV Name & Date Learning Outcomes and Assessment Criteria Pass Merit Distinction LO1 Understand the principles of procedural programming LO2 Be able to design procedural programming solutions P1 Provide an introduction to procedural programming M1 Discuss on characteristics and features of procedural programming D 1 Critically evaluate the design of your solution against the characteristics and features of procedural programming. P2 Identify the program units and data and file structures required to implement a given design M2 Review the design of a procedural programming solution. P3. Design a procedural programming solution for a given problem Assignment Brief 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. Task 1 To prove your programming ability to be appointed to this small project, please prepare an illustrated guide on programming in general and a particular emphasis on procedural programming. Here you will need to include introduction to computer programming languages and discuss key features of procedural programming. Task 2 Your next task is to do the analysis for the scenario mentioned above by doing the following subtasks

  • Identify the variables and data types required in the program.
  • Identify and describe 2 different selection structures, including the condition(s) to check; state why they are needed and where they can be used in the context of the scenario.
  • Identify and describe any iteration constructs.
  • Split the program into functions (sub-functions) and draw a hierarchy diagram to illustrate the structure of your program. Task 3 You need to use a drawing tool to draw design diagram for your program, includes:
  • A use case diagram for actions required
  • Flow chart diagrams for: menu operation, printing IDs and grades, finding max grade and finding min grade.
  • Review / evaluate your design, state clearly pros vs cons and which needs to improve, using characteristics of procedural programming as bases to discuss. Write a report for 3 tasks above and submit the report to CMS in PDF format. Submission Format The submission is in the form of an individual written report. This should be written in a concise, formal business style using single spacing and font size 12. You are required to make use of headings, paragraphs and subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing system. Please also provide a bibliography using the Harvard referencing system.
  • Unit 0: Procedural Programming ASSIGNMENT
  • 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:
        1. Definition:
        1. Advantage and Disadvantage C language:
      • 2.1. The advantages of C language:
      • 2.2. Disadvantages of C language:..........................................................................................................
      1. Definition of Procedural Programming:
      1. Criteria to select a programming language to use:
      • 4.1. Type of application:
      • 4.2. The complexity of the application:
      • 4.3. Maintainability:
      • 4.4. Security:
      • 4.5. Scalability and performance:
  • P2. Identify the program units and data and file structures required to implement a given design:...............
      1. Variables and Data Types:
      • a. Variable:
      • b. Data Types:
      1. Identify the variables and data types required in the program:
      • Primitive (Primary) Data Types
      1. Conditional statements:
      • 3.1. “Switch case” statement:
      • 3.2. “If” statement:
      • 3.3. “If…else” statement:
      • 3.4. “If…else if” statements:
      1. Iteration Structures:
      • 4.1. For Statement:
      • 4.2. “While” statement:
      • 4.3. “Do…While” statement:
      1. External modules:
      • Stdio.h library:
      • Printf() function in C language:
      • Scanf() function in C language:
      • String.h library:
      • Math.h Library:
  • P3. Design a procedural programming solution for the Student Management System:
      1. Hierarchy diagram:
      1. Use case diagram for actions required:
      1. Flowchart:
      • 3.1. Select menu function:
      • 3.2. Input students information:
      • 3.3. Print students information:...........................................................................................................
      • 3.4. Print the highest student’s grade:
      • 3.5. Print the lowest student’s grade:
      1. Psuedo code:
      • 4.1. Pseudocode for select menu function:
      • 4.2. Pseudocode for input student’s information:
      • 4.3. Pseudocode for print student’s information:
      • 4.4. Pseudocode for print highest Grades:
      • 4.5. Pseudocode for print lowest Grades:
  • M1. DISCUSSES ON CHARACTERISTICS AND FEATURES OF PROCEDURAL PROGRAMMING:
      1. There are 5 key features of procedural programming:
      1. Characteristics of Procedural Programming:
  • M2. REVIEWS THE DESIGN OF A PROCEDURAL PROGRAMMING SOLUTION:.................................................
  • OF PROCEDURAL PROGRAMMING: D1. CRITICALLY EVALUATES THE DESIGN OF YOUR SOLUTION AGAINST THE CHARACTERISTICS AND FEATURES
    • Advantages:
    • Disadvantages:
  • REFERENCES

P a g e | 1 ASSIGNMENT 1 ANSWERS

P1. Introduction to Procedural Programming:

1. Introduction to Computer Programming Languages:

a. Definition: Writing a strategy for a computer to perform one or more tasks, computer programming languages are known as special-purpose languages designed for programmers. It defines a set of coding rules that help programmers create guidelines for performing computational tasks. Different programming languages have their own rules. Computer Programming Languages b. Classification of Programming Languages:

  • High-level Languages: It is the programming dialect with a capable deliberation that gets from computer program data. When the software engineers utilize these applications, they can produce the program without the consent of the point-by- point format of the specific machine which runs its program. It implies that software engineers don't ought to ponder computer plans and take note of tackling the issues. Due to this, they are moreover called Problem-Oriented Dialects. Examples: C, C++, JAVA,…
  • Low-level languages: It could be a programming language with non-powerful reflection. The software engineers ought to ponder computer plans carefully due to a profound understanding of computer format for composing the program for such

P a g e | 3 C++ Languages C# Languages

2. C language:

P a g e | 4

1. Definition: C is a high-level, general-purpose programming dialect that's perfect for creating firmware and convenient applications. Dennis Ritchie developed C for the Unix Working System at Bell Labs in the early 1970s to compose a writing system software. C is one of the foremost widely-used programming dialects, with compilers for all intents and purposes for every computer stage. It has impacted several other dialects, the foremost eminent of which is C++. 2. Advantage and Disadvantage C language: Advantage & Disadvantage C Language

P a g e | 6 Since C is based on ASCII characters, it works well over diverse stages counting Windows, Linux, Mac OS X, Android, iOS, etc. In this manner, you'll be able to run your C programs anyplace in any case where you live. g) Easy debugging: Since C doesn't require complex articulations like circles, conditionals, factors, capacities, clusters, pointers, etc., you'll investigate your code effectively. For illustration, in case you experience issues while executing your program, just press CTRL+D to stop the method quickly. At that point, you'll essentially step back one line and proceed to work until you reach the tricky articulation. h) Procedure Oriented Language: Users make methods or capacities to execute their errands in C Dialect. It's exceptionally simple to memorize a procedure-oriented dialect since of the way it works (calculation to execute the articulations you type in). On the off chance that you need to create a program using a procedure-oriented dialect, you wish to outline a calculation and begin changing over it into a function. i) Speed of Compilation: The C compiler produces machine code exceptionally quickly. Near to a thousand lines of code can be put together in a handful of seconds. The C Compiler makes the code more productive for quicker execution. j) Execution of algorithms and data structures: Execution of calculations and information structures. The utilization of calculations and information structures in C has made program calculations greatly fast and smooth. Hence, the C dialect can be utilized in complex estimations and assignments. k) Dynamic memory allocation: In C languages you'll be able to distribute memory powerfully or statically. In energetic allotment, we do not know how much space will be required for our information structure at run time. But if we use inactive allotment at that point we ought to save a settled sum of memory sometime recently beginning the execution of the application. So this highlight makes us more adaptable than other dialects like Java where we must pronounce all factors as last. 2.2. Disadvantages of C language: a) Lack of Object Orientation: C may be an exceptionally tremendous and capable dialect and essentially takes after the procedural programming approach. It doesn't amplify its bolster to the concept of OOPs. Here, you can't take a course with numerous legacies like Java, Python, or C++. In OOP dialects like

P a g e | 7 Java, we are able to acquire strategies from the parent lesson. But there's nothing comparative within the C dialect. We cannot make subclasses for our classes. So it makes it troublesome to reuse existing codes. b) Inefficient Memory Management: In C languages you do not require any memory administration methods since it naturally oversees all distributed assets for you. But in case you need to utilize energetic allotment at that point you ought to distribute powerfully by malloc work. If you are doing this physically at that point, you may get a division blame mistake. So we must continuously keep in mind almost Memory Administration Strategies. c) No Garbage Collection: Trash collection may be a feature that consequently recovers memory from objects not required by an application or library. It can be utilized for both automatic and manual rubbish collection. Programmed waste collection happens when there's deficiently free space on the pile to distribute modern objects; this may happen since all accessible physical Slam was apportioned to other forms running on the computer framework. The manual waste collection includes expressly liberating unused squares of memory with calls to capacities such as malloc. But in C/C++ languages, there's no such highlight of waste collection as the culture of these dialects is to take off capacity administration to the engineer or software engineer. Subsequently, it would be repetitive and cruel on pockets to execute an exact waste collector for C / C++. d) Run-time checking: Within the C programming, the blunders are not identified after each line of code. The compiler shows all the blunders within the code as they were amid the run-time of the complete which makes the checking of code (debug) especially complex in gigantic ventures. Also, the compiler doesn't check whether a variable was pronounced sometime recently utilize. The software engineer must keep in mind this run the show while composing programs. e) Concept of namespace is not present in C: C doesn't carry out the thought of namespaces. The namespace is a chain of commands to allow the reuse of names in different settings. Without namespaces, we can't articulate two components of a comparative title. However, C programming is destitute of this include, and subsequently, you can't characterize a variable with the same title in C. f) Absence of Exception Handling: Extraordinary case Taking care of is maybe the most component of programming tongues. Whereas compiling the code, distinctive blunders and bugs can happen. Special case Dealing with grants you to distinguish the bugs and rectify them. Be that because it may, C doesn't appear as this noteworthy feature.

P a g e | 9 Web applications, portable applications, implanted firmware, etc. The sort of application you’re developing intensely impacts what dialects are accessible for us to select from. General programming dialects like Java, JavaScript, Python, and C# can construct distinctive sorts of applications on diverse stages. There are cases where particular dialects work way better. For example, building a local Android app requires knowledge of Java, and creating a local iOS app requires a Swift or Objective-C ability set. At the same time, the information in C or C++ is basic on the off chance that you’re working with embedded firmware. 4.2. The complexity of the application: The size and complexity of a extend play a vital part in choosing which stack or innovation we need to utilize, which in turn may be a choosing figure on what programming dialect to utilize. Little ventures such as straightforward showcasing locales, portfolio presentations, and basic web application shapes to gather information can be done with a few CMS frameworks like WordPress or Umbraco, which require information of PHP or C#, separately. Medium-sized ventures counting e-commerce locales, inner undertaking applications, and IoT arrangements ordinarily have distinctive layers, components, and integrative where a more common programming dialect such as Java or C# may offer assistance rearrange ability set prerequisites to preserve the items. We regularly break down complex applications into littler components where each element serves a particular work and employments a diverse innovation stack and dialect to abdicate the most excellent result. 4.3. Maintainability: Each innovation stack and dialect comes with a biological system of libraries and seller underpins for those libraries. We need to see at the slant and upgrade discharge cycles to create beyond any doubt what we choose is current and remains current for a few times to come. Whereas we like to lock in with our clients long-term, we get it that at some point we may move a codebase to another group. In case you arrange to enlist an inner engineer group to preserve your innovation stack, maintenance costs will be affected by the accessibility and mastery of advanced ability in your region. For illustration, within the Midwest, it’s simpler to enlist Java and C# designers than Ruby, Python, or PHP designers. We take this into

P a g e | 10 consideration when selecting a programming dialect to guarantee the long-term supportability of the codebase. 4.4. Security: Each application has distinctive prerequisites in terms of security. For illustration, healthcare- related applications might require HIPAA compliance or monetary applications might require PCI compliance. We moreover take more common security suggestions just like the OWASP Best 10 into thought when choosing the proper stack. Keeping an eye on the security bulletin for your chosen stack will offer assistance to the application be more vigorous. It’s vital to note that in a post-monolithic computer program world, innovation choices aren’t commonly selected within an application environment. We’re progressively actualizing microservice models so we are able to run personal administrations built on disparate programming dialects and systems. In that way, ready to guarantee that each particular assignment is being served by the leading conceivable stage. With our breadth of encounter and mastery and by staying to the trademarks of great code – Viability, Straightforwardness, DRY, Strong, and Testability, we are able reliably to guide our clients to the most effective technology solution. 4.5. Scalability and performance: Scalability is more around an innovation stack, which in turn decides the programming dialects instead of the programming dialect itself. A few battle-tested and well-known stacks that have demonstrated to be able of such versatility incorporate .NET, Light, Cruel, and Java Spring.

P2. Identify the program units and data and file structures required to implement

a given design:

1. Variables and Data Types: a. Variable: A variable may be a title for a memory zone where a program may change information. This area is utilized to store the variable’s esteem. The C variable’s esteem can be modified within the program. Here, the sort must be a substantial C information sort counting char, w_char, int, float, double, bool, or any user-defined question; and variable_list may comprise one or more identifier names isolated by commas. A few substantial announcements appear here.

P a g e | 12 The program utilizes an add-up to primary factors. Three drift factors and three int factors are included. The table underneath contains data on these factors, such as their names and information sorts.

2. Identify the variables and data types required in the program: Table of Variables Variable’s name Data type Explanation Grade[50] float It is the pupils' grades using float because it allows to use real numbers. IDs[50] int It displays identification int since it only contains integers. Max ID, Min ID int - It displays the ID with the highest or lowest grade.

  • chose int since it only contains integers. Choice int - It keeps the options that the user selects.
  • chose int since it only contains integers. Max/min float - int it only contains integers.
  • It encompasses both integers and real values, chose float. I, j int - They are utilized in loop functions in array functions as numerical numbers.
  • chose int since it only contains integers. n int - It lists the total number of enrolled.
  • chose int since it contains integers.

P a g e | 13 Primitive (Primary) Data Types These data types store fundamental data used in the C programming such as integer(int), floating-point(float), char, etc.

  • int It is used to store integer values. C program compiled with GCC compiler (32-Bit) can store integers from - 2147483648 to 2147483647. The size of int is compiler-dependent. It takes 4 bytes in a 32-bit compiler such as GCC.
  • float It stores real numbers with precision up to 6 decimal places. It takes 4 bytes of memory and is also known as a floating-point number.
  • double It stores real numbers with precision up to 15 decimal places. It takes 8 bytes of memory.
  • char It stores single characters such as ‘a’, ‘Z’, ‘@’ etc. including numbers, symbols, or special characters. It takes 1 byte (8-bits) to store each character. These are made by collection or combination of primitive data types and are hence known as derived data types. Dedicated to each topic of the following:
  • Array
  • Structure
  • Union
  • Enum
  • Pointe