0% found this document useful (0 votes)
18 views

Variables

Uploaded by

ajay babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Variables

Uploaded by

ajay babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Variables

A variable is nothing but a name given to a storage area that our programs can
manipulate
The programming languages like C/C++/JAVA, the variables can be attached
with the something called a data type.
The programming languages like javascript / python where we don't use
data types they already depend on the data type, it is already inherited
that means for example I want to store some integer value (10), then in
C/C++/Java I need to define like this int a=10.
the same thing If I want to use the same thing in python or javascript
simply we can do like this a=10 or var a=10 respectively.

Data type
The data type or simply type is an attribute of data that tells the compiler or
interpreter who the programmer intends to use the data.

Primitive & Abstract


Primitive data types are those supported directly by the language and are not
further composed of any other data types. The programming language
allows/provides different operations on those data types

Abstract data types are created by users, and in libraries using the primitive
ones and provide more complex operations and can store complex data (like the
one with hierarchy, network, etc.).

Memory Allocation
int a =10

when the above code is written, what exactly happens is, the compiler allocates 4Bytes
of memory to the variable a and it assigns value 10 to a

Assume that integer is going to take 4Bytes. so whenever we want to print the value of
a, then use simply print(a) so a will points to the address in memory where 10 was
stored.

arr[5] = [1, 2, 3, 4, 5]

when I write the above statement, then 20 Bytes of memory is going to allocate to the
array because each element is an integer and each integer is going to take 4bytes, so
a total of 5 elements. therefore the size array is 20Bytes.

Each element in the array can be accessed using its indices, like arr[0], arr[1], etc.

You might also like