A computer is an electronic device used for storing and processing information. Most computers follow the basic principal of input, process, and output for any problem. To perform these input, process, and output activities, computers need a set of instructions called a program.
Objectives
You will learn about:
- Input And Output requirement of a computer problem
- Programs and Programming Language
- Various tool for problem solving
Input, Process, And Output
You might have noticed computers being used at airline reservation counters, shops, restaurants, and various other locations. At each of these places, a user enters some values in the computer and the computer generates an output, which is either displayed on the computer screen or printed on paper. Let us consider the example of an airline reservation counter. When you want to reserve a seat on a particular flight, you provide information about your requirements such as destination, date and time of your department, and the class in which booking is required. The executive at the reservation counter enters this information into a computer. Details regarding the availability of tickets are then displayed on the screen.
The preceding automated process is not carried out as one activity. It is broken down into a set of activities that are carried out in separate phases. Let us see what are the phases involved and the process followed for each of the tasks.
Phases
To understand what happens when you enter some in the computer, let us break the entire set of activities into separate phases. In the first phase, flight required the key into the computer. This Phase is called the input phase. The flight requirement information is then processed to determine whether seats are available on a particular flight. This phase is known as the process phase. Once the processing is complete, the result is displayed on the computer screen, indicating the status of seat availability. This phase is called the output phase. The cycle of activities performed by a computer is known as the Input-Process-Output (I-O-P) Cycle.
I-P-O Cycle
A computer consists of several components such as a keyboard, a mouse, a monitor, and a Central Processing Unit (CPU). Each component participates in either one of the input, process and output phases. For example, the keyboard and mouse are used for input. The CPU and the memory inside the CPU are used for processing. The monitor and printer are used for output. The following figure depicts the I-P-O cycle.
Input --- > Process --- > Output
↑_________________________↓
Program
A Computer needs a set of instructions called a program the i-p-o cycle.
How Does a computer function ?
A computer is designed to accept input, process it , and generate output. However , it has to be provided with a set of instruction that specify :
- The kind of input that will be provided.
For example, in the case of reservation request, flight date, flight time, class, and destination will be some of the inputs. - The processing that need to be done.
For example, accepting the values, checking for availability of seats,and displaying result. - The kind of output expected.
For example, the seat availability status.
Therefore, for each job that you want the computer to perform, you required a separate program. Instruction in a program can be :
1. Sequential:
Instruction that are executed one after the other.
2. Decision making:
Instruction that evaluate an expression (relation or condition) first and then , depending upon whether the value of the expression is true or false , it transfer the control to particular statement.
3. Iterative:
Instruction that are executed repeatedly, depending on the values of an expression (relation or condition)
Programming Languages
A computer is made up of a number of electronics components, An electronic state can be state on or off. Therefore, the components of a computer are represented as a combination of on or off states. The on state represented by 1 and off state represented by 0.This implies that computer can understandonly 0s1s. Therefore, any instruction given to a computer must be a sequence of 0s and 1s.
A computer system uses a number system that consists of only two digits, o and 1, which is called the machine language. For example the following table displays the machine code of the commans, ADD and SUBSTRACT.
Compilers
A compiler is a special program that process that processes the statements written in a particular programming language and convert them to machine language at one go. Like everything else in the computer, the compiler also follow the I-P-O cycle. It takes the programming language instruction as input It then processes these instructions to convert them to machine language.
These instruction can then be executed by the computer. This process of conversion is called compilation. For each programming language, there is a different compiler available.
For example for compiling a program written in C Language, you require a C compiler, and likewise, for a JAVA program , you require JAVA compiler.
Tools used in Problem Solving
Program is a set of instruction to solve a particular problem.
Before we actually start writing a program, we need to derive a procedure to solve a problem can be represented by using the following types:
Algorithm
Algorithm is a sequence of step required to solve a problem. It is a list of well-defined instruction to solve a problem. According to D.E. Knuth, a pioneer in the field of computer science, an algorithm has the following characteristics:
- An algorithm ends after a fixed number of steps.
- Each step in an algorithm clearly specify basic operation.
- These operation could include calculation, input/output operation and comparison.
- An algorithm accepts input data, in a defined format , before it can be processed.
- An algorithm generates one or more output after the input is processed. The resultant information termed as output can be displayed or stored for future reference.
For Example, Withdraw required amount from an ATM , the algorithm will be in the steps as follow:
- Start the algorithm.
- Go to any local ATM.
- Insert/swipe your ATM card.
- Press the language Button that you want to choose.
- Enter the pin code number.
- Press the account type(Saving or Current)button from which you want to withdraw money.
- Press the Cast withdrawal button.
- Enter the amount you want to withdraw.
- Get the amount from the ATM machine.
- Check the statement from the ATM machine.
- Collect your ATM card.
End the algorithm.An algorithm follows the I-P-O cycle to solve a problem. Here, the input to withdraw a required amount from ATM would be the ATM card, the pin code number, and the amount the amount you want to withdraw.
This input are the accepted and the process of withdrawing the amount take place. At the end of the process, the amount, which is the output, is drawn.
Consider another algorithm that displays the product of two numbers:
- Start the algorithm.
- Get the first number.
- Get the second number.
- Multiply the two numbers.
- Display the result.
- End the algorithm.
Flowchart
A flowchart is graphical representation of an algorithm .It consists of set of symbols. Each Symbol represents a specific kind of activity depicted in the algorithm. A typical problem would involves accepting input, processing the input, and displaying the output. The processing would involve the computation and the decision that are begin taken.
Advantages of flowchart:
- Help in analyzing the problem effectively.
- Act as guide during the problem development phase.
- Easy debugging of logical errors.
Disadvantages of flowchart:
- A lengthy flowchart may extend over multiple pages, which reduces readability.
- Drawing a flowchart using any graphical tool is a time consuming process.
- The change Made to a single step may cause redrawing the entire flowchart.
Pseudo code
This is detailed yet readable description of what an algorithm must do, expressed in a formally styled natural language rather than in programming language.
Pseudo code is used as an initial step in a process of developing a program.
It provides programmers a detailed template for writing instruction in a specific programming language.
Advantages of Pseudo code
- It is easy and fast to write as it uses English like statements.
- It needs no rewriting if any changes are made in the steps. This is because each step is written dependent of the other.
- It can be converted to a program by using any programming language. This is because the format used by Pseudo code is similar to a program. The contain a set of sequential statement using a defined set of keywords.
Limitations of Pseudo code
- Pseudo code does not provide a graphical representation of an algorithm; therefore, it might be difficult to understand the complex logic in a Pseudo code.
- Pseudo code depicting too many nested condition may be difficult to understand.
Comments: