What is a computer program?
A computer program is referred to as a set of instructions (known as code) to be carried out by the computer’s CPU. They can be categorized into three major categories: operating systems, utilities, and applications.
A program mainly has modules and submodules which are stored as a collection of files. Some of the files have instructions while another category has data. In Window-based PCs, these exist some common extensions for program files, which include:
- Executable files – it is the part of the program that sends commands to the processor. If you are running a program then actually you are running an executable file. The processor executes the commands present in a file, that’s why they are named as an executable file. It has the file extension .exe.
- Dynamic Link Library Files– it is a partial .exe file. This type of file doesn’t run on their own rather they are accessed by another running program. They also provide an effective way of breaking large programs into smaller ones that can be replaceable, thus making it easy to upgrade.
- Initialization Files (.ini)– this is composed of configuration information, such as size and the starting point of the window, the color of the background, etc. They help programs start running or also contain information that programs can use as they run. Modern programs use the Windows Registry- a special database that contains information about the user of the computer, installed applications, and hardware devices.
- Help Files (.hlp)– it contains information in an indexed and cross-linked format. This enables the user to provide online help information.
- Batch Files (.bat)– their responsibility is to automate common or repetitive tasks. A batch file is a simple file that composed of unformatted text files. these files contain operating system commands. Typing a batch file’s name at a command prompt will execute the commands in the file.
Planning a Computer Program
Programs are sometimes difficult to write. Writing it without planning may often lead to a bad one. If the planning is done beforehand, the programmer will have an idea of what needs to be done. Two planning tools that programmers use are pseudocode and input-processing-output(IPO) charts.
Pseudocode is a natural language statement that resembles code. It is the logical step to solve a problem and describes what must be done. They can be written by non-programmers.
Example of a pseudocode to create a program which will add 2 numbers and display the result
Enter two numbers A,B.
Add the numbers
Print the sum
Input-Processing-Output (IPO) Charts:
They help the programmer to determine what is needed to write. It has three columns. The first one is the input column in which the data is entered by the user. The middle one is the processing column. And the last one is the Output column in which the desired output is displayed.
IPO chart that calculates average of 3 numbers.
|Number A||Input number A||avg|
|Number B||Input number B|
|Number C||Input number C|
Learn more about IPO charts here.
How programs solve problems?
Programs solve problems by using some techniques stated below:
Program Control Flow
After launching the program the computer begins the reading and carrying out statements at the first line of the file. After executing the first statement control passes to another statement depending on the previous one and thus executes the last statement of the program after which it ends. The order in which the statements are executed is referred to as program flow control.
The steps in the IPO charts lead to some result and this sequence of steps is referred to as Algorithm. An algorithm is a series of step-by-step instructions that produce a specific result.
A graphical sequence of steps, similar to the pseudocode but easier to read and understand. Specific symbols are used to represent different programming constructs. A flowchart can be used to:
- Analyze various processes.
- Construction of a step-by-step image of the process.
- Used to write high-level language code.
The below figure shows some of the standard symbols that are used in drawing a flowchart.
EXAMPLE OF FLOWCHART
Add 10 and 20
Algorithm (in simple English)
• Initialize sum = 0 (PROCESS)
• Enter the numbers (I/O)
• Add them and store the result in sum
• Print sum (I/O)
Also check : Data Processing in computer