Chapter Zero
Chapter Zero
Chapter Zero
is an artificial language that can be used to control the behavior of a machine, particularly a
computer
Programming languages, like natural language (such as Amharic), are defined by syntactic and
semantic rules which describe their structure and meaning respectively.
What is syntax?
The syntax of a language describes the possible combinations of symbols that form a syntactically
correct program.
The process in which all z steps are done starting from the feasibility study up to the development
of the exact system
A program is not needed only to solve a problem but also it should be reliable, (maintainable) portable and
efficient.
can be used to define the problem in terms of the steps to its solution Example- flowcharts and
structure chart that
1.2.1. Algorithm
An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in
which these actions execute
a step-by-step sequence of instructions that must terminate and describe how the data is to be
processed to produce the desired outputs
algorithms are a fundamental part of computing
Three commonly used tools to help to document program logic (the algorithm)
Pseudo Code
Structured chart,
Flowcharts
Pseudo Code kkg
is a compact anjkd informal high-level description of a computer algorithm that uses the
structural conventions of programming languages, but typically omits details such as subroutines,
variables declarations and system-specific syntax
The purpose of using pseudo code is that it may be easier for humans to read than conventional
programming languages, and that it may be a compact and environment-independent generic
description of the key principles of an algorithm
No standard for pseudo code syntax exists, as a program in pseudo code is not an executable
program.
Example:-
Original Program Specification:
Write a program that obtains two integer numbers from the user. It will print out
the sum of those numbers.
Pseudo code:
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result
Flowcharts
is a schematic representation of an algorithm or a process
it doesn’t depend on any particular programming language, so that it can be used to translate an
algorithm to more than one programming language
Flowchart uses different symbols (geometrical shapes) to represent different processes
Example: - Write an algorithm description and draw a flow chart to check a number is
negative or not.
Algorithm description
1/ Read a number x
2/ If x is less than zero write a message negative
else write a message not negative
Loop is a sequence of instructions, which is repeated until some specific condition occurs.
A loop normally consists of four parts:-
Initialization: - Setting of variables of the computation to their initial values and setting the
counter for determining to exit from the loop.
Computation: - Processing
Test: - Every loop must have some way of exiting from it or else the program would endlessly
remain in a loop.
Includes:-
a. Organizational Feasibility
How well the proposed system supports the strategic objectives of the organization.
b. Economic Feasibility
Cost savings
Increased revenue
Decreased investment
Increased profits
c. Technical Feasibility
Hardware, software, and network capability, reliability, and availability
d. Operational Feasibility
End user acceptance
Management support
Customer, supplier, and government requirements
The system is tested to ensure that interfaces between modules work (integration testing), the
system works on the intended platform and with the expected volume of data (volume testing)
and that the system does what the user requires (acceptance/beta testing).
1.4.8. Maintenance
What happens during the rest of the software's life: changes, correction, additions, moves to a
different computing platform and more. This, the least glamorous and perhaps most
important step of all, goes on seemingly forever.
Low-level languages
High-level languages
Programming paradigm
Provides the programmer's view of code execution. The most influential paradigms are examined
in the next three sections, in approximate chronological order.
3 programming paradigm
Procedural Programming Languages
Procedural programming specifies a list of operations that the program must complete to reach
the desired state. Each program has a starting state, a list of operations to complete, and an ending
point.
This approach is also known as imperative programming. Integral to the idea of procedural
programming is the concept of a procedure call.
Procedures, also known as functions, subroutines, or methods, are small sections of code that
perform a particular function. A procedure is effectively a list of computations to be carried out.
Procedural programming can be compared to unstructured programming, where all of the code
resides in a single large block. By splitting the programmatic tasks into small pieces, procedural
programming allows a section of code to be re-used in the program without making multiple
copies. It also makes it easier for programmers to understand and maintain program structure.
Two of the most popular procedural programming languages are FORTRAN and BASIC.
It provides additional tools to manage the problems that larger programs were creating.
Structured programming requires that programmers break program structure into small pieces of
code that are easily understood.
It also frowns upon the use of global variables and instead uses variables local to each subroutine.
It is often associated with a "top-down" approach to design. The top-down approach begins with
an initial overview of the system that contains minimal details about the different parts.
Subsequent design iterations then add increasing detail to the components until the design is
complete.
The most popular structured programming languages include C, Ada, and Pascal.
In object- oriented programs, the designer specifies both the data structures and the types of
operations that can be applied to those data structures. This pairing of a piece of data with the
operations that can be performed on it is known as an object.
A program thus becomes a collection of cooperating objects, rather than a list of instructions.
Objects can store state information and interact with other objects, but generally each object has a
distinct, limited role.
#endif
1.7.9. Assertions
The assert macro-defined in the <cassert> header file-tests the value of an expression. If the value of the
expression is 0 (false), then assert prints an error message and calls function abort (of the general utilities
Iibrary-<cstdlib>) to terminate program execution. This is a useful debugging tool for testing whether a
variable has a correct value. For example, suppose variable x should never be larger than 10 in a program.
An assertion may be used to test the value of x and print a n error message if the value of x is incorrect.
The statement would be
assert ( x <= 10 ) ;
If x is greater than 10 when the preceding statement is encountered in a program, an error message
containing the line number and file name is printed, and the program terminates.
The programmer may then concentrate on this area of the code to find the error. I f the symbolic constant
NDEBUG is defined, subsequent assertions will be ignored. Thus, when assertions are no longer needed
(i.e., when debugging is complete), the line
#define NDEBUG
is inserted in the program file rather than deleting each assertion manually. Most C + + compilers now
include exception handling. C++ programmers prefer using exceptions rather than assertions. But
assertions are still valuable for C++ programmers who work with C legacy code.