Back to: C#.NET Tutorials For Beginners and Professionals

**How does the computer work?**

In this article, we will be discussing some of the fundamentals before learning a programming language to get awareness about a few things. Mostly in academics, these are the basics that are taught. So, to get the awareness about the computers, so that everyone can understand how to use the computer means how to write the programs.

**How does the computer work?**

Let us discuss how does the computer works. To understand how computer works, please have a look at the following basic block diagram of a computer and understand the different components of a computer.

Let’s study the components of a computer. The computer consists of the following components.

**CPU- Central Processing Unit.****Main Memory****Hard disk****Input devices****Output devices**

Let us understand the components in detail.

**CPU**

CPU is the heart of the computer. CPU stands for Central Processing Unit or Microprocessor. The Brain of the computer is the CPU where actual data manipulation or Operations happens using ALU (Arithmetic and logical unit). If you see the present-day processors like i3, i5, i7, etc. The CPU is consisting of two components i.e. ALU (Arithmetic Logic Unit) and CU (Control Unit).

**ALU- Arithmetic Logic Unit:**ALU performs the basic logical and arithmetic operations. Arithmetic operations like addition, subtraction, multiplication, division, and modulus. Logical operations like comparing two numbers (such as >, <, >=, <=, etc.), logical AND, OR, NOT, etc. So, ALU has performed these basic operations.**CU- Control Unit:**Control unit controls the other components like Input and output devices, main memory, hard disk, etc. The job of the control unit is to utilize other resources effectively.

**Hard Disk:**

A hard disk is the storage device for a computer. It contains two types of files, i.e. data files and program files. We can store data or programs on the hard disk and when we store something on the hard disk, then it is permanent storage.

If you take an example of the notepad on our computer, it is a program file. So, when we open notepad it’s a program and there is a file available. So, basically, we click on the notepad icon and the program will start, but if you look into My Computer and folders, somewhere you will find the program file for the notepad (**C:\Windows\System32**) and the file name will be notepad.exe. Now, if you type something on the notepad, and save it, then it will save as a text file such as **MyDoc.txt** and it is a data file and this data file is used by notepad or generated by notepad. For better understanding, please have a look at the below diagram.

**Program files:** The music player in the computer or notepad in the computer are program files. Any application or software installed on the computer is program files.

**Data files:** Movies, Songs, Word Documents, etc. are types of data files. It contains actual data. In order to write/reads into the data, we actually need a program file.

**Main Memory:**

Whenever the user wants to run any program (program files), then it should be present in the main memory so that the CPU can execute it. That means the program needs to be brought from the Hard Disk into the Main Memory so that it can be executed by the CPU. This is the reason why Main memory is also called working memory or Primary Memory.

Once the program is brought to the Main memory, the only CPU executes the program line by line. So, whatever program we run, they are brought into the Main memory. If the program needs some data from the keyboard or if it has to display some data on the monitor, then it can utilize the INPUT and OUTPUT devices.

**Input Devices:**

Input devices are keyboard, mouse, etc. These devices are used to give inputs to the computer. Input devices have their own memory in the computer called Input Buffer. All instructions from input devices are dumped into this memory and if the program wants to read something, then it will read from the input buffer. So, whatever we type using the keyboard will be stored in the input buffer and the program reads the input from the input buffer.

**Output Devices:**

Output devices are monitors, printers, etc. Output devices show the output after the execution of the program file. Output devices also have their own memory called output buffer. If the program wants to print something, then whatever it wants to print will be put in the output buffer and that will appear on the output screen.

Above are the components of a computer system and this is how a program works inside it. You might have one question in your mind about how a computer understands the programming language or instructions. So, let’s look at it. The computer only understands the binary number system.

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 that the computer performs receives data in the form of 0’s and 1s and manipulates the data using logic gates.

**Introduction to 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 Human Beings follow, is the Decimal number system but the computer understands only the Binary Number System. So again, there is a difference between how we saw the number and how the computer saw it.

**Example:**

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

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

Basically, we use the decimal number system and in the decimal number system, the pictures or figures or the symbols are from 0 to 9 i.e. total of 10 symbols we have. As we already discussed the computer works on zeros and ones. So, for computers, there are only two symbols and the binary number systems have only two symbols i.e. 0 and 1.

In the decimal number system, once we have finished with the last symbol i.e. 9, after 9, we use the combination of symbols (from 0 to 9). For example- 10, 11, 12, and so on. 10 is the combination of two symbols i.e. 0 and 1 similarly 11 is the combination of 1 and 1.

So, the point that you need to understand is that once we finished with the symbols, then we can take the combination of symbols and in the binary number system, the same methodology is also followed. To denote the new number, we use the combinations of two symbols i.e. 1’s and 0’s.

For example, to denote 2 in the binary system we will use the combination of 1 and 0 i.e. 10, don’t read it as ten, read it as one zero. For more details, please have a look at the following which shows the numbers from 0 to 16 in the Decimal, Binary, Hexadecimal, and Octal number system.

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

We have discussed binary and Decimal number systems, then what is these hexadecimal and octal number system. See, remembering a number as 0, 0, 1, 1 is too top. We need a simple method. So, what people have done, to make decimal and binary number systems simple, octal number system introduced. Let’s, look at how we convert Decimal numbers to a binary system.

**How to Convert Decimal Number to Binary Number?**

For example- 29 is the decimal number and let’s see how we can convert this decimal number into a binary number. As we discussed the base for the binary number is 2 and hence, we need to perform successive division 2 and take the remainder and then read the remainders from bottom to top to get the binary number as shown in the below image.

This is how a decimal number is converted into binary. Now, we will see how to convert a binary number to decimal form. For example – 10101 is the binary number and we need to find out its equivalent decimal number. For a better understanding, of how to convert please have a look at the following diagram.

So, this is how we can convert a binary number to a decimal number. We have seen how to convert decimal numbers to binary and binary numbers back to decimals.

In the next article, I am going to give a brief **Introduction to Programming Languages**. Here, in this article, I try to explain How does a computer works in detail and I hope you enjoy this **How does the computer work** article.