Skip to main content

Basics of Programming : Variables

Variables


Before going into definition of variable, let us consider any mathematical equation which we have studied in our schools.
For example consider, 2x + 5y = 35

We do not have to know the use of this equation, but we just know that we can substitute some values for x and y which can satisfy the equation. For example (x,y) can take values (10, 3) or (5, 4). So we can say that x and y can hold some values or x and y can are placeholders for some data.

In the same way we need something for holding data in computers. Those are called as variables.

In other words we can also say that, variables are the name given for memory location. Since data are stored in some memory location, variables are the labels for those memory locations.




Comments

Popular posts from this blog

Linux Kernel - Introduction

Linux Torvalds developed the first version of Linux in 1991 as an operating system for computers powered by the intel microprocessor.   Started as a terminal emulator Linux evolved over a period. What is an operating system ? The operating system is considered as a part of the system responsible for basic use  and administration. This includes the kernel and device drivers, boot loaders, command  shell or other user interface and basic file and system utilities. The term system, in turn  refers to the operating system   and all the application running on top of it. The user interface is the outermost portion of the operating system, the kernel is the  innermost. The kernel sometimes referred as the supervisor, core or internals of the  operating system. Typical components if the kernel are interrupt handlers to service  interrupt requests, a scheduler to share the processor time among multiple processes,  a mem...

Basics of Programming : Data Types

We have seen that variables are placeholders for data. When we say data, it can be a integral numbers like 3,5 or it can be a real number like 2.6 , 1.8. In computer science, we define different types of data which we can store in memory location. A data type in a programming language is set of data with predefined values. Examples include, integers, floating point, characters, Strings etc. Even though ultimatly everything in memory stored in terms of zeros and ones, it is not practical  for us to code interms of zeros and ones. So to help users with programming compilers provide programmers the data types, which are in readable data which we use in day today transactions. The data types are categorized based on the representation in memory or the size it occupies in memory. For example, integer takes 4 bytes ( depends on the compiler, some may take 2 bytes), float takes 4 bytes, a character takes 1 byte. There are two types of data types. System define...