Note on Concept of Program and Programming statement

  • Note
  • Things to remember

CONCEPT OF PROGRAM

Introduction

A program is a set of instructions or statements to perform some specific tasks. It is a composed list of instructions that commands a computer to perform a particular job. An instruction is also called a statement and a group of statements is composed to form a program.
A program is composed of a main module and sub-modules which are stored as a collection of files. Some files may contain instructions while the others contain data.

d


Some examples of program files are:

  1. Executable file (.exe or .com): This part of program sends commands to the processor which then executes those commands of the file. Their file extension is .exe or .com.

  2. Dynamic Link Library file (.dll): This is a partial executable file which does not run independently. Commands of these files are shared among several programs.

  3. Initialization files (.ini): Configuration information like size and starting point of a window, a color of background, user’s name and so on is contained in this file.

  4. Help files (.hlp or .chm): This file contains help information about the programs.

FEATURES / QUALITIES OF A GOOD PROGRAM

  • Integrity: It means that the calculations used in the program should be very accurate. It must provide the desired output for the given input. It must do the work according to the specification.
  • Clarity: The program should be well readable to help maintenance later. This can be provided in-line documentation or external documentation. On in-line documentation, the function of each piece of code is defined within the program itself. In the external documentation, a separate report includes the working principle of each inside the program.
  • Simplicity: The program should be able to express the logic in a considerably simple way. This feature enhances integrity and clarity. The same problem can be solved in two or more ways, but one needs to choose the simplest way to solve the problem.
  • Efficiency: The program should have a good compromise between time and space used; it means it should run as fast as possible with the minimum memory requirements.
  • Modularity: Program should be separated to different logical and self-contained modules. If the entire program is divided into simpler modules, then one can easily understand what’s happening inside it.
  • Generality: It should be flexible and easy to operate with a wide range of platform.
  • Robustness: Program should be fault-tolerant as much as possible. A program cannot be 100% full-proofs. So, it must be built in such a way that, if some unavoidable circumstance appears, then it must tackle with it without being crashed.
  • Security: A program must be secured enough so as to avoid tampering from unwanted people. All the loopholes in the programs must be avoided as much as possible.
  • Documented: Documentation helps for smooth operation for the users and even helps for further modification and maintenance.

Differences between Program and Software:

Program

Software

It is a set of instructions which instructs computer to perform a specific job.

It is a collection of instructions, programs, and data which instruct the computer on how to solve computer problems.

It is independent.

To develop software, collections of programs are needed.

It is a component of software

It is a logical unit driving the computer system.

It defines the computer process.

It defines both data and process.

A programmer creates programs.

Software is created by groups of programmers as a team.

It is not generally licensed for sale.

It is generally licensed under a company.

It cannot be divided in accordance to needs and uses.

It can be divided under various needs and uses like application software, utility software, system software, etc.

Example: SYS, FoRMAT.SYS, interest calculations, etc.

Example: MS Word, Adobe Photoshop, Internet Explorer, etc.

(Bhusal, Khanal, & Manandhar, 2013)

CONCEPTOF PROGRAMMING STATEMENT

An instruction (also called code) written in the high level language to do a specific task in a program is called programming statement. Each programming statement commands the computer to do some specific task such as input, output, calculation or some logical decisions. One program statement in high level language may result in several instructions in machine language when the program is compiled. Programming statement may consist of keywords, variables, operators, control structures, data type, library function, user defined function, etc.

There are 3 types of Programming Statements used in programs. They are:

  1. Simple statement: It is a basic part of a program and it’s a single line expression which is used to carry out an assignment, calculation or to test logical decision. Example:

X=10 - assign integer values 10 to X variable

a>=50 - logical statement to check whether a is greater than or equals to 50 or not.

  1. Compound statement: Compound statement is defined as a statement which consists of two or more individual instructions. Example:

A= l*b
where one instruction is for multiplication of l and b and another instruction is for assigning multiplication value to the variable A.

  1. Control Statement: A statement that affects the flow of execution through a program is called a Control Statement. Control statements are also called control structures in high level languages which are their basic building blocks. There are 3 types of control statements. They are Sequence, Selection and Iteration (repetition).

Testing and Debugging:

Programs are not always perfect. Some always have limitations about them causing them to have errors and such program errors are called bugs. The process of locating and correcting them after their detection is known as debugging. Testing is the process where it is made sure that the program performs the intended task and debugging is where they locate and correct program errors. Though time-consuming, these 2 are very important steps in program development.

n

Fig. Testing and debugging

Source: www.slideshare.net

There are several stages of testing. They are:

  • Unit testing involves the individual components’ testing.
  • Integration testing involves the separate components’ testing as they are put together.
  • System testing that involves the whole final form of a program testing.
  • User acceptance testing involves the user testing the program to see that it is the result what is required.

Debugging is basically done to find:

  • Syntax error: The error which occurs when the instruction of program does not match the structural rule of the programming language is called syntax error
  • Semantic error: Semantic errors are the errors which causes the wrong output due to wrong calculation or wrong input of data.
  • Run-time error: The error which appears during the execution or runtime of a program is called runtime error. Such errors appear when the computer is asked to divide by zero or when the variable is assigned a large value which is beyond its capacity. The run-time error causes the termination of program execution.

Syntax and Semantics:

j

Fig. Describing Syntax and Semantics

Source: slideplayer.com

Syntax:
The rules that we use while writing code is called Syntax. A syntax is the grammatical rules of writing the programming statement. In other words, the syntax is the rules that tell us whether a string is a valid program or not. The error which is detected by the computer if we violate the rule of writing programming statement is called Syntax error.

Semantics:
The rule that gives the meaning to programs is called Semantics and the error which occurs in program logic is called Semantic error. It is also calledlogical error. The semantic error is not detected by the computer and the compiler compiles it successfully. We can only see the error after the program is being executed and gives out the wrong output. So, it is very difficult to find the semantic or logical error because no satisfactory method has been found to detect the logical error yet.


For example:

Statements

Descriptions

I eat fruits.

Syntactically & Semantically correct.

I eat a laptop.

Syntactically correct but Semantically incorrect.

I eats laptop.

Both Syntactically & Semantically incorrect.

Also, when a program is running, it is said to be at runtime and if any error occurs while the program is executing, it is called aRun-time error. For example: peripheral devices may not be turned on.

(Koirala & Shrestha, 2015)

Bibliography

Bhusal, R., Khanal, R., & Manandhar, S. (2013). Computer Essentials I. Putalisadak, Kathmandu: Asmita's Publication.

Koirala, H., & Shrestha, R. K. (2015). Computer Science I. Anamnagar, Kathmandu: Buddha Publication.

  • Features of a good program.
  • Differences between Program and Software.
  • Types of programming statement.
  • Testing and Debugging.
  • Syntax, Semantics and Run-time error.
.

Very Short Questions

0%

DISCUSSIONS ABOUT THIS NOTE

You must login to reply

Forum Time Replies Report

Why logical error are difficult to detect and correct than syntax error?


You must login to reply