COMPUTER PROGRAMING
These process can take quite a number of times, maybe hours, days and months to be resolved. The uses of computers are almost limitless in our everyday lives.
Various activities done in 21st century is been aided by mean of computer. Many jobs done by human is now replace with computer programs.
Sophisticated operations and manipulations are made simple and fast by computer. Computers can do such a wide variety of things because they can be programmed.
This means that computers are not designed to do just one job, but to do any job that their programs tell them to do. A computer machine without a computer program is just a dump box and thus computer program brings a computer machine to live state.
In these study we shall be discussing preliminary properties of programing with other application of high level coding.
A program is a set of instructions with sequential format that help in the solution of a particular task.
The process of writing computer programs to perform a task in the computer is called computer programming.
Programing involves the process of developing or combination of various programs to perform a task or computation.
Computer program is a sequence of instructions written using a Computer Programming Language to perform a specified task by the computer.
A computer program is also called a computer software.
SOME USES OF COMPUTER PROGRAMING
Its important cannot be over emphasis and unlimited to the below listed.
Today there are being used in almost every field, household, agriculture, medical, banking, entertainment, defense, communication, etc.
Following are few applications of computer programs:
1) MS Word, MS Excel, Adobe Photoshop, Internet Explorer, Chrome, game, ATM machines etc., are example of computer programs.
2) Computer programs are being used to develop graphics and special effects in movie making.
3) Computer programs are being used to perform Ultrasounds, X-Rays, and other medical examinations.
TWO TYPES OF COMPUTER PROGRAMING LANGUAGE
1. High level language
2. Low level language
LOW LEVEL LANGUAGE (TARGET MACHINE/OBJECTIVE/PRIMARY CODE)
This is the oldest and original form of computer language in which the computer understand and read easily. All computers contains inbuilt programs that aids the solution of primary computations.
The major disadvantages of this language is the inability to solve effectively high mathematical and scientific problems.
The major disadvantages of this language is the inability to solve effectively high mathematical and scientific problems.
HIGH LEVEL LANGUAGE (SECONDARY/SOURCE CODE)
These language comes into existence to solve the high scientific computations that are not proficient with low level. They are more easy and portable to use, debug error, and understand by human.
The major disadvantage ii that computer cannot understand it, therefore requires an intermediary for the translation to objective code before execution. One advantages of the method is that the program can be compiled, store and be reuse in the future. Example of high level languages are Java, C, C++, Python, PHP, Ruby, HTML, CSS, and BASIC etc.
EXECUTION OF A HIGH LEVEL LANGUAGE
This is basically achieved using an integrated development environment (IDE). It involves the use of intermediary to translate secondary code to primary code because the computer is designed to read only the objective codes. Therefore, a translator is needed.TWO TYPES OF TRANSLATOR
a) Interpreter
b) Compiler
INTERPRETER
These translate programs line by line and execute it simultaneously. Interpreted language can be easily debug and cannot be stored. The disadvantages is that, the program has to be translate when needed to be use and it makes the program run slowly because you cannot go to the next line until it is properly debug.
Examples of such programs are Python, PHP, MATLAB and Perl, which do not need any compilation into binary format, rather an interpreter can be used to read such program line by line and execute it directly without any further conversion.
COMPILER
This is use to convert from text formatted program (source code) into binary format file. Finally, you can execute binary file to perform the programmed task. Compiled language I more efficient because it combine numerous lines of source code and convert them to object code for execution at the same time. This code can be debug and saved to be used in the future.
Examples of such programs are Java, C++, C, Pascal etc.
Following flow diagram gives an illustration of the compilation process;
SOURCE CODE (PROGRAM FILE) INTERPRETER PROGRAM EXECUTION
SOURCE CODE (PROGRAM FILE)
COMPILER PROGRAM EXECUTION BINARY CODE (OBJECT FILE)
SOURCE CODE (PROGRAM FILE) INTERPRETER PROGRAM EXECUTION
SOURCE CODE (PROGRAM FILE)
COMPILER PROGRAM EXECUTION BINARY CODE (OBJECT FILE)
ERRORS AND DEBUGGING
Computer programming is not void of errors. They are refers to as bugs. The process of dictating such error and eliminate it is called Debugging.BASICALLY THREE TYPES OF ERROR;
a) Syntax or compilation error
b) Logical or Semantic or definition error.
c) Runtime or execution error.
If you do not follow rules defined by the programing language then at the time of compilation you will get syntax error and program will not be compiled.
Syntactically, even a single dot or comma or single semicolon matters and you should take care of such small errors within the codes.
SYNTAX ERROR
This is an error encountered due to abused of rules and structures guiding a particular programming language during compilation period. This type of error can be easily dictated because the integrated development environment (IDE) will indicate it with error message and underline. Also with options regarding the specific incorrect token in the program.If you do not follow rules defined by the programing language then at the time of compilation you will get syntax error and program will not be compiled.
Syntactically, even a single dot or comma or single semicolon matters and you should take care of such small errors within the codes.
A compile-time error results from the programmer’s misuse of the language. A syntax error is a common compile-time error.
For example, in English one can say
The boy walks quickly.
This sentence uses correct syntax. However, the sentence
The boy walk quickly.
Is not correct syntactically: the number of the subject (singular form) disagrees with the number of the verb (plural form). It contains a syntax error. It violates a grammatical rule of the English language.
The boy walks quickly.
This sentence uses correct syntax. However, the sentence
The boy walk quickly.
Is not correct syntactically: the number of the subject (singular form) disagrees with the number of the verb (plural form). It contains a syntax error. It violates a grammatical rule of the English language.
Similarly, the C++ statement
x = y + 2;
is syntactically correct because it obeys the rules for the structure of an assignment statement. However, consider replacing this assignment statement with a slightly modified version:
y + 2 = x;
If a statement like this one appears in a program and the variables x and y have been properly declared, the compiler will issue an error message;
y + 2 = x;
If a statement like this one appears in a program and the variables x and y have been properly declared, the compiler will issue an error message;
for example, the Visual C++ compiler reports (among other things):
error C2106: ’=’ : left operand must be l-value
The syntax of C++ does not allow an expression like y + 2 to appear on the left side of the assignment operator.
Syntax errors are in two formats
a) Tokens, which are the elements, word or characters of the language which
on misuse will generate error. b) The Structure, this is the manner and pattern of arrangement of the program which when altered will attract error.
error C2106: ’=’ : left operand must be l-value
The syntax of C++ does not allow an expression like y + 2 to appear on the left side of the assignment operator.
Syntax errors are in two formats
a) Tokens, which are the elements, word or characters of the language which
on misuse will generate error. b) The Structure, this is the manner and pattern of arrangement of the program which when altered will attract error.
LOGICAL ERROR
This is an error due to wrong intension and definition. It is difficult to indicate because an error message will not show when there is a disruption in the intended meaning of the program.
Example, a programmer wanted to add two numbers and mistakenly input division sign, it will produce and answer without error message but the actual intention of the program is been defeated. It requires a diligent search to identify this error and time consuming.
RUNTIME ERROR
This is an error that occurs during the execution of the program that cause a program to terminate abnormally. The user enters illegal and unexpected defined data.
Example, if the user types in a string when the defined data type expected by the computer is number, it will experience a runtime or execution error.
Note: The program (source code) must be compiled and build before execution, following storage and retirement.
Note: The program (source code) must be compiled and build before execution, following storage and retirement.
STAGES OF PROGRAM DEVELOPMENT
1) Program definition and identification: At this first stage, the programmer need to take a breath to critically understand the task and most effective means to achieve it.
2) Algorithm Design: This is a step-by-step procedure to resolve any problem. It is an effective method expressed as a finite set of well-defined instructions and not the real code. Thus, a computer programmer lists down all the steps required to resolve a problem before jumping to write actual code.
It can be expressed in three format.
a) Flow chart
(b) Pseudo code and
(c) Decision table.
The commonly used method is flow chart and pseudo code. Flow chart is the pictorial or graphical representation of the constructive pattern to performing a given task. Pseudo code also known as false code are basically mathematical expression of the logical step in solving a problem. It is close to the real code. Decision table are tabulation of different procedures to performing a particular task.
3) Coding: this involves the transformation of the algorithm into a particular programming language. These requires an in-depth knowledge of a particular programming language is need to complete this stage.
4) Program Testing: this occurs in two part. a) Compilation: At these stage, the source code is been transformed to object code and it’s been tested to know if it is performing the intended function followed by corresponding execution. b) Debugging: Any error encountered during the compilation and testing is removed
5) Documentation and retirement: in this state, the programmer will make a clear definition of the various operation using comments and save the program for future use. This is refers to as user guideline.
FEATURES OF A GOOD COMPUTER PROGRAMS
1) Less sophistication i.e. easy to use.
2) Quickly responsibility and intelligent.
3) Easily understand, study and expressed in précised designed language.
4) Robustly documented. 5) Easily accessible.
6) Elimination of duplication and errors.
7) Portability.
8) Readability.
9) Efficiency.
10) Structural 1
1) Flexibility