Procedural Programming_ Assignment 1 of Information technology, Summaries of C programming

Procedural Programming_ Assignment 1 of Information technology

Typology: Summaries

2020/2021

Uploaded on 10/02/2021

reen-nie-1
reen-nie-1 🇻🇳

1 document

1 / 50

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:
ID: GCS200674
Class: GCS0905C
Subject code: PROG102
Assessor name: PHAN MINH TAM
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

Partial preview of the text

Download Procedural Programming_ Assignment 1 of Information technology and more Summaries C programming in PDF only on Docsity!

Higher Nationals in Computing

Unit 0: Procedural Programming

ASSIGNMENT 1

Learner’s name:

ID: GCS

Class: GCS0905C

Subject code: PROG

Assessor name: PHAN MINH TAM

Assignment due: Assignment submitted:

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date: Signature & Date:

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 D1 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

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.

Table of Contents P1. Provide an introduction to Procedural Programming: ……………………………………………... 1 1.Introduction to computer programming language: …………………………………………………. 1 1.1. Low-Level language and high-level language:.............................................................................. 2 1.2. Command language, compiled language and interpreted language:………………………….. 5 1.3. Criteria for choosing a program language to use:………………………………………………, 8

2. Introduction to Procedural Programming:....................................................................................... .. 3. Key features of Procedural Programming:....................................................................................... 10 4. Advantages and Disadvantages of Procedural Programming: .......................................................... P2. Identify the program units and data and file structures required to implement a given design: ...................................................................................................................................................... 13 1. The variables and data types required :............................................................................................ 1.1. The variables:............................................................................................................................. 1.2. The data types in C programming:............................................................................................. 2. Five data types in Procedural Programming:................................................................................... 15 2.1. String Data Type:....................................................................................................................... 2.2. Character Data Type:................................................................................................................. 2.3. Integer Data Type:..................................................................................................................... 2.4. Float Data Type:......................................................................................................................... 2.5. Boolean Data Type:.................................................................................................................... 3. Selection structures:......................................................................................................................... 17 3.1. If statement:.............................................................................................................................. 3.2. If-else statement:....................................................................................................................... 3.3. If-else if statement:.................................................................................................................... 3.4. Switch-case statement:..............................................................................................................

ASSIGNMENT 1 ANSWERS

P1. Provide an introduction to Procedural Programming: 1.Introduction to computer programming language:

  • Programming language is a formal language comprising a set of strings that produce various kinds of machine code output. Programming languages are one kind of computer language, and are used in computer programming to implement algorithms. Programming language is a computer language, used to write software, scripts or instructions for computers followed.
  • Standard programming languages according to a system of separate rules, so that the programmer can describe the programs for electronic devices that both people and those devices understand.
  • Each programming language can be viewed as a set of technical details focusing on syntax, vocabulary, and meaning of language.
  • These specifications often include: ● Data and data structure ● Statements and control lines ● Names and parameters ● Reference mechanism and reuse
  • Programming languages can be divided into some of the following models: ● Low-level language and High-level language. ● Command language - Compiled language - Interpreter Language. 1.1. Low-Level language and high-level language: Page | 1
  • Programming languages fall mainly into two different classifications: low-level language and high-level language. ❖ Low-level language: Provide very little or no abstraction and the syntax is very complex, close to machine language. Low-level language is a program language that provides little or no abstraction from a computer's instruction set architecture—commands or functions in the language map that are structurally similar to processor's instructions. Generally, this refers to either machine code or assembly language. Because of the low (hence the word) abstraction between the language and machine language, low- Page | 2

before execution. Because computers can only understand the machine language, all high or low languages must be converted into machine language. Language language translates into low-level language. With the help of these languages, we can write mobile applications on many different platforms and are independent of all architectures. High-level high-end language and user friendly. Low-end language is suitable for developing new operating systems or writing basic program code for microcontrollers. High-level language is a highly abstract language compared to computer languages. Low-level language is a language that is closely related to computer hardware, so the speed will be faster. High-level language is more flexible. They are mainly used to write software that can run on multiple platforms and architecture. Low-level programming language is really confusing, the code is written for an assembly language that cannot be run on a different language. In addition, high-level languages are the place where all new creative things are created and it can be much easier to fix bugs than low-level language. Low-level language really challenges programmers Page | 4

and requires a lot of experience and knowledge we have. 1.2. Command language, compiled language interpreter language: Page | 5

Command language can express complex possibilities rapidly. Compiled language: is a programming language whose implementations are typically compilers (translators that generate machine code from source code), and not interpreters (step-by-step executors of source code, where no pre-runtime translation takes place). The term is somewhat vague. In principle, any language can be implemented with a compiler or with an interpreter. A combination of both solutions is also common: a compiler can translate the source code into some intermediate form (often called p-code or bytecode), which is then passed to an interpreter which executes it. Programs compiled into native code at compile time tend to be faster and more efficient than those translated at runtime due to the translation process's overhead. Newer technologies such as just-in-time compilation, and general improvements in the translation process are starting to narrow this gap, though. Mixed solutions using bytecode tend toward intermediate efficiency. They also give the developer more control over hardware aspects, like memory management and CPU usage. Compiled languages need a “build” step – they need to be manually compiled first. You need to “rebuild” the program every time you need to make a change. Examples of pure compiled languages are C, C++, Erlang, Haskell, Rust, and Go. Interpreted language is a computer program that repeatedly reads instructions (one at a time) and translates them to machine code. It then executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interpreter generally uses one of the following strategies for program Page | 7

execution: ● Parse the source code and perform its behavior directly. ● Translate source code into some efficient intermediate representation or object code and immediately execute this. ● Explicitly execute stored precompiled code made by a compiler which is part of the interpreter system. Interpreted languages were once significantly slower than compiled languages. But, with the development of just-in-time compilation, that gap is shrinking. Examples of common interpreted languages are PHP, Ruby, Python, and JavaScript. 1.3. Criteria for choosing a program language to use: The right selection of programming language yields solutions that are concise, easy to debug, easy to extend, easy to document, and easy to fix. The support and community. It is very important to consider the platform on which the program will run. Say you have two Page | 8

based on the concept of the procedure call. Procedures (a type of routine or subroutine) simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. The first major procedural programming languages appeared circa 1957–1964, including Fortran, ALGOL, COBOL, PL/I and BASIC. Pascal and C were published circa 1970–1972.

  • 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.
  • Simple 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.
  • 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. Page | 10

Procedural programming has program code that 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.

3. Key features of Procedural Programming:

  • Modularity means logical partitioning of complex software to make it manageable: in terms of implementation and maintenance. In Procedural Programming, modularity is when two dissimilar systems are grouped to execute a larger task. Every system has different tasks that it completes one after another until all tasks are finished.
  • There are also called Built-in functions provided by language processors (compiler/interpreter) mostly in high- level programming languages. A predefined function is an instruction identified by a name. They are derived from the registry or programming libraries instead of a program. Take “charAt()” built-in function as an example that searches for a character position in a string.
  • In simple terms, a variable that is declared within the structure of a method is called a local variable. Such variables are limited to their given local scope. A local variable can only be used in the method, in which it is defined. If we use a local variable outside the defined method, the code will generate an error.
  • A variable that is declared outside every other function defined in a program is called a global variable. Due to this reason, a global variable can be used by all functions in a program, unlike a local Page | 11