Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Islamabad
Procedural
Programming
Unit 18
TABLE OF CONTENTS
INTRODUCTION 1
WHAT IS PROGRAMMING? 1
CHRONOLOGY OF LANGUAGES 2
|2.1|IDENTIFY THE PROGRAM UNITS, DATA AND FILE STRUCTURES REQUIRED TO IMPLEMENT A GIVEN DESIGN. 7
|3.1|SELECT AND IMPLEMENT APPROPRIATE CONTROL STRUCTURES TO MEET THE DESIGN ALGORITHMS. 9
|4.1|CRITICALLY REVIEW THE DEVELOPED CODE BY IDENTIFYING SYNTAX, LOGICAL AND RUNTIME ERRORS. 13
|4.2|ANALYSE ACTUAL TEST RESULTS AGAINST EXPECTED RESULTS TO IDENTIFY ANY DISCREPANCIES. 15
High-Level Language
What is Programming?
The art of solving a program by breaking it down into various sets of instructions written
in a particular language that, when given to a machine, can be executed to perform
the desired task, also known as computation.
1
\\Chronology of Languages\>
There are numerous programming languages in today’s world. Each developed for its
own purpose. Some are unavailable or restricted. Some abandoned and some are
basically derived or compiled from other languages.
2
\\Learning Outcome No.1\>
Understand the principles of procedural
programming.
\\Definition\>
\\Explanation\>
With one or several procedures in a program, the procedural language is splits into
variables, functions, statements and conditional operators. For performing tasks,
functions and procedures are implemented on the data and variables. Such
procedures are available anywhere within the program and can be invoked by other
operations as well.
\\Example\>
C Python Ruby
C++ Fortran MATLAB
C# Pascal ECMAScript
Java COBOL Basic
3
|1.1|Discuss the principles, characteristics and features of
procedural Programming\>
Before actually writing any program, a plan is developed in simple language that is
similar to a flowchart describing all the necessary arguments and statements.
All procedural languages have great differences between them based on how they
express, also, their range or extensibility of data types, facilities for modularity
implementation and run-time execution characteristics.
Several programming languages have descended based on C’s syntax such as C++,
Pearl, JavaScript, etc.
ALGOL BCPL B
INTERNATIONAL GROUP MARTIN RICHARDS KEN THOMPSON
1960 1967 1970
ANSI/ISO C C 99 C 11
ISO COMMITTEE STANDARDISATION COMMITTEE STANDARDISATION COMMITTEE
1990 1999 2011
4
\\Principles of {C} Language\>
The fundamental design principle for this procedural language is based on the
concept of “divide & conquer”, and is termed as the functional decomposition or
top-down design. The overall effort of the program is to separately disintegrate into
smaller logically subtasks, until each remaining sub task is adequately limited in scope
so as to permit employment within an operation of fittingly small size.
\\Code Example\>
Following is a brief list of C’s characteristics that define this widely used professional
language.
5
There is no input or output facility nor any read and write statement or file accessing
methods. All these are high level functions that are required to be explicitly called.
This language has been superseded by other languages like C++, C#, Java.
The size of the language is small and function calls are broadly used.
Extensive pointer implementation use for memory, array, structures and functions.
Flexibility Control over the language with predefined reserved words and
access to low-level facilities.
\\Code Example\>
6
\\Learning Outcome No. 2\>
Be able to design procedural
programming solutions.
\\Problem Definition\>
Design a Tic Tac Toe game program for two players. Allow them to place their marks
on the board. Determine and print the match result, with declaring the respective
player’s win or match being a tie. Additionally, it may offer a choice to play again.
\\Problem Analysis\>
•Declare •Print
Winner or Draw
•End
7
|2.2|Design a procedural programming solution for the given
problem \>
\\Design Solution\Pseudocode\>
Start: Game
Print: Introduction
Clear: Screen
Print: Board
Switch: Player
Print: Result
End: Game
8
\\Learning Outcome No. 3\>
Be able to implement procedural
programming solutions.
The control structures that are intended to be implemented to meet the design
algorithm in this problem are as follows.
If \>
While \>
To keep the game running until someone wins or match becomes a tie.
Do While \>
For creating conditions in which a place cannot be replaced for the same round.
And to create a complete game loop if the user wants to play again.
9
Goto \>
Necessary to break from within the loop if the match becomes a tie.
And to finish the game immediately if someone wins before the end of cycle.
Call by Value
10
|3.3|Implement the {C} language solution based on the
prepared design\>
11
Program Complete.
12
\\Learning Outcome No.4\>
Be able to test procedural programming
solutions.
\\Syntax Error\>
Nominal syntax errors were located and resolved such as the following\>
\\compiler’s message\>
\\compiler’s message\>
13
\\Logical Error\>
Program is failing to declare win for 2nd player but executes successfully for the 1st.
- - Player 1 - - - - Player 2 - -
Another problem is that there is no input limit applied, so program can take any
input but if it is not within the defined space, it does not show on screen and skips to
the next player.
\\Run-time Error\>
If ‘%s’ was chosen for storing variable character in the matrix ‘M [ ] ’, the following
run time error was displayed.
It was handled by changing the ‘%s’ to ‘%c’, and the program executed successfully.
14
|4.2|Analyse actual test results against expected results through
sample test data to identify any discrepancies\>
\1\Testing Phase\Launch\>
\2\Testing Phase\Input\>
15
\3\Testing Phase\Complete\>
Thus, this program will not be able to handle false string input instead of integers.
16
|4.3|Evaluate the feedback for the above analysis and make
recommendations for the improvements in your solution\>
Recommendations \>
17
New menu has been created with the addition of more features\>
18
|4.5|Create documentation which should provide support for
the maintenance of this C program\>
\\Code Maintenance\>
All support for code maintenance is given within the written code of the program\>
19
Program Complete.
20
\\Technical Support\>
21