Computer Algorithms  «Prev  Next»
Lesson 3Computer organization
ObjectiveList and describe the components of a computer.

Structured Computer Organization

A computer can be described as an electronic machine that processes data. At a fundamental level a computer simply accepts input, performs some processing, and produces output. As an example, consider how a computer is used to perform the payroll functions for a small business. The processing that takes place is the calculation of the pay due each employee. The input to this process is the number of hours worked and rate of pay for each employee, and the output is the employee checks. The following diagram illustrates this model.

Input/Output diagram
Input/Output diagram

Components of a Computer

The components of a computer are shown in the following diagram.
CPU: This is the brains of the computer. The CPU executes the instructions contained with the computer programs
1) CPU: This is the brains of the computer. The CPU executes the instructions contained with the computer programs.

RAM: Random Access Memory: RAM contains the programs being executed by the CPU along with the data being processed. The CPU can read from and write to RAM very quickly.
2) RAM: Random Access Memory: RAM contains the programs being executed by the CPU along with the data being processed. The CPU can read from and write to RAM very quickly. RAM is volatile storage, the contents of RAM are lost when the power to the computer is turned off. RAM is also referred to as main memory or primary storage.

Long term storage: This includes hard disks, CD-ROMS, and DVDs. These are used for long-term storage of programs and ata, and capable of holding vast amounts of information.
3) Long term storage: This includes hard disks, CD-ROMS, and DVDs. These are used for long-term storage of programs and data, and capable of holding vast amounts of information. Long term storage is non-volatile and the contents of long term storage are not lost when the power to the computer is turned off. Long term storage is also referred to as second storage.

I/O devices: Input and output devices. 
These devices allow you to communicate with the computer. An input device such as a keyboard, mouse or joystick allows you to input data to the computer.
4) I/O devices: Input and output devices. These devices allow you to communicate with the computer. An input device such as a keyboard, mouse or joystick allows you to input data to the computer, while an output device such as a monitor or printer allows you to see what the computer has done.

In the context of structured programming, the primary components of a computer and their relevance are as follows:
  1. Central Processing Unit (CPU): The CPU is the brain of the computer where most calculations take place. It is crucial in structured programming for executing program instructions and logical operations.
  2. Memory:
    • RAM (Random Access Memory): This is the primary working memory used by a computer, where data and programs in use are temporarily stored. In structured programming, RAM is vital for storing the state and variables of a program during execution.
    • ROM (Read-Only Memory): Contains the instructions for booting up the computer and basic operations. It’s less directly involved in structured programming but essential for the overall operation of the system.
  3. Storage Devices:
    • Hard Drives/Solid State Drives (HDD/SSD): These are used for long-term data storage, including the storage of program files and related data in structured programming.
  4. Input Devices (Keyboard, Mouse): These are used to input data and commands into the computer. In structured programming, they are essential for user interaction.
  5. Output Devices (Monitor, Printer): These display or output the results of a computer’s processes, including the outcomes of structured programs.
  6. Motherboard: The motherboard connects all of the computer's components and allows them to communicate with each other. It's critical for integrating the CPU, memory, and other components necessary for running structured programs.
  7. Power Supply Unit (PSU): Provides the necessary power to all the computer components. While not directly involved in programming, it is essential for the functioning of the computer.

In structured programming, these components work in unison to execute programs efficiently and reliably, adhering to structured paradigms like sequence, selection, and iteration.

Input and Output on a Computer

When we talk about input and output in computing, we describe all forms of communication between a program on the computer and the outside world, which includes human end users, other programs on the same machine, or other programs running on other computers. Input includes all the data and signals received by the running program. For instance, input can be sent to a program using input devices such as a keyboard or mouse, or can come from other computers, such as when you use your web browser to load in a specific web page. Output on the other hand includes all the signals and data sent from a program. Monitors and printers are prime examples of output devices, but again, output can involve pure data, such as when your web browser sends a request to a web server to receive a web page. The latter immediately illustrates that the same program (a web browser) can involve a series of input and output operations. The same holds for hardware devices, such as a network card or a modem. A particular form of I/O we will be taking a closer look at in this chapter is file I/O, meaning input and output operations that read and write data to files stored on your computer. We can skip the details until we are ready to start dealing with files in Java, but two aspects are worth mentioning:
  1. file modes and
  2. the difference between text and binary files as they apply to programming languages other than Java.

Input and Output

Interaction in programming is described as input/output (I/O). Of course, this communication flows in two directions, one in the form of output, which is information the program provides to outside parties, and the other in the form of input, which is information users provide to the program or information the program reads in from the outside world. It is easy to imagine a multitude of cases where such functionality could be useful. Imagine a program asking the user's name, for instance, or a program asking if it should terminate or ignore an error when something unexpected happens. These aspects are all covered in this chapter. Interaction can happen not only between a program and a human end user, but can also involve other sources of information. Consider, for example, the fact that so far, whenever you closed and restarted a program, all its previous data values were lost. When writing a budget tracking application, you cannot expect your users to leave the program running indefinitely (what if the power goes out?) or expect them to re-enter all the information once they reopen the program. As such, you will also deal with ways of handling I/O between your program and data sources. This chapter covers the most basic of data sources, namely that of a file.

You are now familiar with the various components of a computer.
The next lesson will explain the role of an operating system.