Computers, Programs and How they Work

Computers and Programs and how they work

In this article, I am going to give a brief introduction to Computers and Programs and how they work. This article mainly focuses on the basics of computers, which is needed before learning any programming language. If you are new/beginner to computer programming then please go through this introduction section as it gives more clarity on how the computer thinks. Why we need programming language etc. But if you have prior experience in programming then you can skip this article. The topics covered in this article are as follows which are related to computers and Programs:

  1. How does the computer think?
  2. What is a program?
  3. What are compiler and interpreter?
  4. What is an operating system?
  5. Introduction to Number System?
How does the computer think?

The computer thinks only in Binary 0’s and 1’s because the whole computer is a circuit. Built from gates (logic gates). So, we can say computers operate only on Boolean algebra. Any Computational /Algebraic or logical task which computer performs, it receives data in the form of 0’s and 1’s and manipulates the data using logic gates.

Now we have an idea of how actually computer brain works but now let us understand how each component interacts with each other.

Introduction to Computer and Programs and how they work

The Brain of the computer is CPU where actual data manipulation happens using ALU (Arithmetic and logical unit). To understand how exactly it works in nonprofessional terms let us take an example. Computer hard disk contains two types of files i.e. program files and data files.

  1. Program files example word pad/MS word etc. any application or software installed on the computer.
  2. Data files, which contain actual data, write/read into the data we actually need a program file.

Now I want to type “hello welcome to C++ course” in MS word. For that, I click on the MS word program file (means MS word application). Here mouse clicks on will be the input which CPU received and the control unit actually maintains or controls all the resources. So Control Unit in CPU contacts the Hard disk or secondary storage and bring the program file into the main memory(RAM) where exactly ALU can access data.

Means main memory is the region where actual program execution happens. Then whatever you type in the keyboard will be processed from CPU which is displayed in the output usually monitor/printer.

What is a Program?

We already talked about the program files in our previous explanation. Here let us talk about what exactly a program means. A program is just an instruction to a computer to perform a specific task. For Example, I instruct my computer to open the application, close the application, etc.

Student: Hey Teacher… you said the program is an instruction to a computer and you also said computer thinks in binary 0’s and 1’s but I am learning here is C++ which from syntax, wise similar to English. I feel awkward about your explanation.

Teacher: Hey wait, I think you are in hurry…! Can you talk with the computer in 0’s and 1’s?

Student: No!

Teacher: Then can you teach a machine English?

Student: NO. From your explanations what I understand is the computer can only understand 0’s and 1’s just like me I understand only English.

Teacher: That is why we need compilers and interpreters when we talk with computers.

Let us take an example to understand this better:

Teacher: suppose you have a client from Spain who knows only Spanish and you know only English how you interact with them.

Student: I appoint a translator when I had a meeting with the Spain client where he/she could translate to me and vice-versa.

Author: Exactly the same thing happens in the case of Computers also. Computers cannot learn our language or we cannot learn the computer language. So, we need a translator who could translate our instruction to the computer and vice versa. Compilers and Interpreters Act as a translator here.

Compiler and Interpreter:

From Definition Compilers and Interpreters transform code written in High-level language (Human understandable language) to Machine Code (Binary code or Machine understandable language).

From the Interview Point of View and Exam Point of View, it is important to know the difference between Compiler and Interpreter.


The compiler translates High-level code (Source code) to Machine code All at once.

Let us take an example: Say you have written a program in a high-level language that does simple arithmetic operations like addition, multiplication, etc. When you give this program to the compiler, the compiler translates all the instructions written in the program to machine code. Then after it gives a full-translated machine code to computers.

Advantage: It is faster when compared to the interpreter as the entire translation happens at one go.


The interpreter translates each High-level instruction to machine code One by one.

We can take the above example, which we used, for compilers. When we give the program to the interpreter, it translates the first instruction and generates the machine code and gives it to the computer. Thereafter second instruction translation and goes on until all the instructions were converted to machine code.

Advantage: If there is a problem in one instruction then the program will be executed till previous instruction.

Difference between Compilers and Interpreter:

Difference between Compilers and Interpreter

Operating System:

Operating System (OS) is a master program, which uses all available resources of the computer, and provides a service to the end-user.

Student: OS is a program? But I never ran the OS or I never instructed the computer to run this master program.

Teacher: Yes, OS is also an instruction maybe you can call it a bunch of instruction to the computer. This is the program that gets autoloaded when you trigger the switch on the button of your PC (means it is an auto-loaded program).

To run any program or instruction in the main memory or on the computer you need a master program that got loaded to the main memory so that it handles all the resources like HDD, Keyboard monitor, etc. In addition, this program runs in the main memory unless you trigger to shut down on your computer.

Commonly used OS for PC is Linux, windows, and mac.

Commonly user OS for mobile is Android, windows, and ios.

Before Jumping into the next Topic, let us know the difference between High-level code (program) and low-level Code.

Difference between High-level Program and low-level Code

Difference between High-level Program and low-level Code

Number System:

Firstly, let us know why we need to understand the Number System while we are learning a programming language. The Number System, which we Humans follow, is the Decimal number system but computer understands in Binary number system. So again, there is a difference between how I saw the number and how the computer sees it.


As a human, if I give 10 for me it is Ten but for the computer, it is two. So, it’s actually necessary to understand the different types of number systems.

  1. Binary Number System: {0,1}
  2. Octal Number System: {0,1,2,3,4,5,6,7}
  3. Decimal number system: {0.1,2,3,4,5,6,7,8,9}
  4. Hexadecimal number system: {0,1,2,3,4,5,6,7,8,9,10, A, B, C, D, E, F}

Number System

The above table gives how we see numbers in each number system. However, one thing here is common when we exhaust with the number then the combination of numbers will come. For Example, in decimal system 0 to 9 after nine, ten is a combination of first and second i.e. 0 and 1 i.e. 10. Similar is holds good for other number systems.

There is a separate chapter where we will discuss the conversion of one number system to another number system in detail.

In the next article, I am going to give a brief introduction to the C++ Programming language. Here, in this article, I try to give a brief introduction to computers and Programs and how they work and I hope you enjoy this introduction to computers and Programs and how they work article.

Leave a Reply

Your email address will not be published. Required fields are marked *