Lesson 2 | Computer programs |

Objective | Define the elements of computer programs. |

Today computers are almost everywhere.

They are in

They are in

- our cars,
- our homes,
- our workplaces, and
- embedded into our cerebral cortexes.

When we write a computer program, we are generally implementing a method that has been devised previously to solve some problem. This method is often independent of the particular programming language being used, it is likely to be equally appropriate for many computers and many programming languages. It is the method, rather than the computer program itself, that specifies the steps that we can take to solve the problem. The term algorithm is used in computer science to describe a finite, deterministic, and effective problem-solving method suitable for implementation as a computer program. Algorithms are the stuff of computer science: they are
central objects of study in the field. We can define an algorithm by describing a procedure for solving a problem in a natural language, or by writing a computer program that implements the procedure, as shown at right for Euclid's algorithm for finding the greatest common divisor of
two numbers, a variant of which was devised over 2,300 years ago.

What is the relationship between structured programs and algorithms?
In the field of computer science, the relationship between structured programs and algorithms is intrinsically linked and foundational. Understanding this relationship is key to grasping the core principles of effective software development.
1. **Definition and Essence**:
- **Algorithms**: An algorithm is a well-defined sequence of steps or rules to solve a specific problem. It's a conceptual entity, independent of any programming language, focusing on the logic behind the solution. Algorithms are expressed in terms of input, output, and the steps required to transform the input into the output.
- **Structured Programs**: Structured programming, on the other hand, is a programming paradigm that emphasizes the use of clear, well-organized blocks of code. It relies on constructs like loops, conditionals, and subroutines (functions or procedures) to create programs that are easy to understand, test, and maintain.
2. **Interdependence**:
- At the heart of every structured program lies one or more algorithms. The algorithm provides the theoretical framework or the 'blueprint' for solving a problem. When this algorithm is implemented in a specific programming language following the principles of structured programming, it becomes a part of a structured program.
- Structured programming provides the tools and constructs to effectively implement algorithms. It allows for translating the abstract steps of an algorithm into concrete code segments. These segments are organized in a logical and orderly manner, enhancing readability and maintainability.
3. **Enhancing Problem-Solving Efficiency**:
- The synergy between algorithms and structured programming enhances problem-solving efficiency in computer science. While algorithms focus on devising the most efficient method to solve a problem, structured programming ensures that this solution is implemented in a clear, logical, and efficient manner.
- This relationship facilitates easier debugging, testing, and future modifications. A well-structured program, built upon a sound algorithm, is more likely to be robust, scalable, and efficient.
4. **Educational Perspective**:
- In computer science education, students first learn the art of algorithm design - understanding how to approach problems, break them down, and devise step-by-step solutions. The next phase is learning structured programming, where these algorithms are brought to life through code.
- This learning process highlights the importance of both: devising a logical solution (algorithm) and implementing it effectively (structured programming).
In summary, algorithms and structured programs are two sides of the same coin in computer science. An algorithm is the theoretical design of a solution, while structured programming is the practical implementation of this design. Together, they form the backbone of effective and efficient software development, emphasizing clarity, precision, and order in the realm of programming.

Computers fly aircraft, make perfect toast, and balance our checkbooks. There are very few parts of our lives where computers are not in some way useful. Some computers fill an entire room and perform highly complex tasks, such as modeling the Earth's atmosphere, while others fit in your pocket and to calculate compound interest. Despite the tremendous range in capability and responsibilities of modern computers, they all have one thing in common: they need to be told how to do their job.

Computers are told how to perform a task or solve a problem through a set of instructions. The set of instructions used in a computer to bring about a specific result is called a computer program; the process of creating a computer program is called computer programming. Computer programs are often referred to as application programs or simply applications.

In many respects, a computer program is very much like a recipe. Just as a recipe tells the cook what ingredients and tools to use and what steps to carry out to prepare a dish, a computer program tells the computer what resources to use and what sequence of instructions to execute in order to achieve the objectives of the program.

Now that you have a general understanding of what a computer program is and what it does, continue on to the next lesson to learn the basic components of a computer.

Computers are told how to perform a task or solve a problem through a set of instructions. The set of instructions used in a computer to bring about a specific result is called a computer program; the process of creating a computer program is called computer programming. Computer programs are often referred to as application programs or simply applications.

In many respects, a computer program is very much like a recipe. Just as a recipe tells the cook what ingredients and tools to use and what steps to carry out to prepare a dish, a computer program tells the computer what resources to use and what sequence of instructions to execute in order to achieve the objectives of the program.

Now that you have a general understanding of what a computer program is and what it does, continue on to the next lesson to learn the basic components of a computer.