2. Master the Basics First: A Simple Introduction to Computers

Before we dive into programming, we should probably understand the machine we are using to do programming. We call that machine – a computer. Luckily, computers run on a very simple rule: you give it an input, it does the processing homework, and then it hands you the output.

Inputprocessoutput
Fig 2.1

WhatsApp Image 2025 07 27 At 12.48.421 682x1024
Fig 2.2

Analogy 2.1: Your juicer takes peeled orange as input, processes those peeled oranges (i.e crushes it separating the juice part and the residue part) and gives the output – juice and residue.

The computer too works on the same principle. It takes input – the data in the form of text, image, audio, video etc. The component which processes the input data is called CPU (Central Processing Unit). The output is then rendered via output device like screen, printer etc.

Fig2.2 1
Fig 2.3

You must be a little curious about the CPU by now.

“Hmm… this seems to be the most important part of the computer!”

And you are right. The CPU is often called the brain of the computer.

When you type something using the keyboard, the instructions (program) and data eventually reach the CPU. The CPU reads the instructions one by one and performs the required operations.

Now please don’t think that the CPU will wash your clothes or make tea for you! 😄 The CPU mainly works with data. This data can be text, numbers, images, audio, or video.

However, the CPU can control hardware devices connected to the computer. For example, it can tell a printer to print a document, an audio player to play a song, or even a bulldozer to start digging the ground if the bulldozer is connected to a computer-controlled system.

So while the CPU cannot physically do the work itself, it can instruct other devices to do it.

What is there inside CPU?

CPU is made up of three components 1) Arithmetic and Logic Unit(ALU) 2) Control Unit(CU) 3) Memory Unit.

Before we see how a CPU executes a program, let’s first understand what each of these components does.

Once you understand them, you’ll also be able to make sense of many of the technical terms that computer manufacturers proudly highlight in their advertisements.

We often say that the CPU is the brain of a computer. While that analogy helps us understand its importance, the human brain is actually far more complex and fascinating than a CPU. In comparison, the CPU follows a much simpler and way of working.

So let’s open up the CPU and see what is happening inside this electronic brain.

Analogy 2.2: Sam’s mother doesn’t want to do the tiring task of going to the market herself. So she gives Sam a list of step-by-step instructions.

Sam listens to the instructions and starts processing them using his brain. Just like a CPU, we can imagine Sam’s brain as having different sections responsible for different tasks.

ChatGPT Image Jul 27 2025 12 46 09 PM 1024x683
Fig 2.4

1) Arithmetic and Logic Unit: One section of Sam’s brain is responsible for calculations and logical decisions.

For example, Sam buys:

1 chocolate

2 pouches of milk costing ₹25 each

1 kg of rice

2 kg of wheat

  • The shopkeeper tells him the total bill amount. However, Sam quickly adds up the prices in his mind to verify that the shopkeeper has calculated correctly.
    Suppose the bill is ₹200 and Sam gives the shopkeeper a ₹2000 note. Sam’s brain calculates how much change he should receive. This involves subtraction.
  • Now consider another instruction from his mother:
    “If tomatoes cost more than ₹100 per kg, don’t buy them.”
    When Sam reaches the vegetable shop, he checks the tomato price and decides whether to buy them. This is a logical decision rather than a mathematical calculation.
    The part of Sam’s brain that performs calculations and makes logical decisions is very similar to the Arithmetic and Logic Unit (ALU) of a CPU.
Sam Anlogy Buying From Shopkeeper 1024x683
Fig 2.5

2) Memory Unit: As the name suggests, the Memory Unit stores information.

Sam needs to remember all the instructions given by his mother:

  • Buy milk
  • Buy rice
  • Buy wheat
  • Don’t buy tomatoes if they cost more than ₹100 per kg

The part of Sam’s brain that remembers these instructions is analogous to the Memory Unit of a CPU.

3) Control unit The Control Unit is like the boss or manager.

It does not perform calculations itself, nor does it store information. Instead, it coordinates and directs all the other parts.

This part of Sam’s brain tells:

  • His legs to walk
  • His hands to pick up items
  • His mouth to talk to the shopkeeper
  • The Memory Unit to recall his mother’s instructions
  • The ALU to perform calculations and logical checks

In short, the Control Unit ensures that everything happens in the correct order and at the correct time.

The Control Unit (CU) inside a CPU performs a very similar role. It coordinates all the components and makes sure the instructions are executed properly.

Sam’s BrainCPU
Calculates prices and decisionsALU
Remembers instructions given by momMemory Unit
Coordinates all activities and actions of SamControl Unit

——Analogy ends——

Now that we have understood the analogy, let’s see how these three components work inside an actual computer.

When we write a program using the keyboard, the computer first stores the program’s instructions in its Memory Unit.

The Control Unit (CU) then reads these instructions one by one from the Memory Unit. Based on the instruction, it directs the Arithmetic and Logic Unit (ALU) to perform the required calculations or logical operations.

The Control Unit can also communicate with other devices connected to the computer. For example, it can instruct a printer to print a document, a speaker to play sound, or a monitor to display information.

In short, the Memory Unit stores instructions, the Control Unit manages and coordinates the work, and the ALU performs the calculations and logical decisions.

Fig 2.6
Fig 2.6

1) Memory unit

The Memory Unit stores:

  • The instructions written in a program.
  • The data required to execute those instructions.
  • Intermediate results produced while the program is running.
  • The final result before it is sent to an output device such as a monitor or print

The Memory Unit stores:

  • The instructions written in a program.
  • The data required to execute those instructions.
  • Intermediate results produced while the program is running.
  • The final result before it is sent to an output device such as a monitor or printer.

For example, suppose we write a program to add two numbers. The computer is so silly that it cannot understand on its own which two numbers you want to add! 😄

So, along with the program, we must also provide the two numbers. These numbers are called data.

The Memory Unit stores both the program instructions and the data needed to execute them.

While the program is running, it may produce temporary or intermediate results. These are also stored in the Memory Unit. Finally, when the answer is ready, it is stored there before the Control Unit sends it to an output device.

2) Arithmetic and Logic Unit (ALU)

The Arithmetic and Logic Unit (ALU) is responsible for performing calculations and making logical decisions.

Arithmetic Operations

The Arithmetic Unit performs mathematical operations such as:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (×)
  • Division (÷)

For example, if a program asks the computer to add 25 and 75, the Arithmetic Unit performs the calculation and produces the result 100.

Logical Operations

The Logic Unit performs logical operations and decision-making.

Some examples are:

  1. Checking a condition: If a condition is true, one set of instructions is executed. If the condition is false, a different set of instructions is executed.For example:If a student’s marks are greater than 35, display “Pass”; otherwise display “Fail”.
  2. Comparing data: The Logic Unit can check whether two values are equal, greater than, or less than each other.For example:Is 100 equal to 100?Is 75 greater than 50?

Just as Sam’s brain performed calculations and made decisions while shopping, the ALU performs calculations and logical decisions inside the CPU.

    3) Control unit

    The Control Unit (CU) is like the boss of the CPU. In a way, it acts as the coordinator of the entire computer. Its main responsibilities are:

    • It fetches instructions from the Memory Unit.
    • It directs the Arithmetic and Logic Unit (ALU) to execute those instructions.
    • It sends the results of execution to output devices such as the monitor or printer.
    • It controls and coordinates the various devices connected to the computer.

      For example:
    • If a keyboard is connected, the Control Unit receives the data typed on the keyboard.
    • If a mouse is connected, it receives information about mouse clicks and movements.
    • If a speaker is connected, it sends sound signals to the speaker.
    • If a printer is connected, it sends instructions to print documents.

      One important thing to remember is that the Control Unit does not perform calculations or execute instructions by itself. Its job is to manage, coordinate, and direct the other components so that everything works together smoothly.

    Remember Trick
    Remember MAC. Many of you may have heard of Mac, the popular computer brand from Apple. Now use the same word to remember the three main components of a CPU:
    M → Memory Unit
    A → Arithmetic and Logic Unit (ALU)
    C → Control Unit So whenever you hear the word MAC, think: Memory Unit + Arithmetic and Logic Unit + Control Unit These are the three major components that work together inside a CPU.

    Side note on MU:Human beings have a single brain that stores information and can remember things even after a long sleep.

    Computers work a little differently. They use two broad types of memory:

    1. Primary Memory – Used while a program is being executed.
    2. Secondary Memory – Used for permanent storage.

    Primary memory stores the instructions and data that the CPU is currently working on. Examples include RAM, Cache Memory, and Registers.

    ram cache

    Secondary memory stores programs and data permanently. The information remains stored even when the computer is switched off. Examples include Hard Disks, SSDs, Pen Drives, Memory Cards, and CDs/DVDs.

    secondary storage

    For simplicity, we referred to all of these as the “Memory Unit” in this chapter. In reality, computer memory is a much deeper topic with many layers and types.

    A detailed study of memory and CPU organization is usually covered in undergraduate subjects such as Computer Organization, Computer Architecture, or similar courses.

    Summary

    • Computer takes input through input devices, process it in CPU & given output through output devices.
    • CPU has three main parts- Memory Unit,Arithmetic and logic Unit and Control Unit.
    • Computer memory can be divided into two parts-Primary Memory and Secondary Memory.

    Next Article