Tuesday, January 5, 2010

DEFINALTION & DESCRIPTION ABOUT Array:

Array:
Array is a very good example of how simple structures combine together to form a composite structure or type. (Composite data types are those that are made of other data types/structure).
An array is defined as a:
• List of values
• All of same type
• Individual elements identified by an index
• Variable holds the address of first element in the list
In the declaration of array an integer is passed which specifies the size of array. Whereas while using the array an integer is passed that indicates the index from which the value should be fetched. Indexes start from zero
Implementation of Array:
In memory arrays are allocated as contiguous blocks. As mentioned that for accessing individual elements it is required to pass an index. This index value multiplied by size of each block is then added to the address of first element of array in order to obtain the address of a particular block.
Multi-dimensional arrays
Arrays can have more dimensions, in which case they might be declared as:-
int results_2d[20][5];
int results_3d[20][5][3];
Each index has its own set of square brackets.
It is useful in describing an object that is physically two-dimensional, such as a map or a checkerboard. It is also useful in organizing a set of values that are dependent upon two (or more) inputs.

WHAT IS THE DATA TYPES & HOW MANY TYPES OF DATA

Data Type:
A data type is composed of two things
• Range of possible values
• Set of operations that can be performed on data.

Initially languages provided a non-extensible data type system. But as the benefits of software technology became clear, people started to apply technology to solve complex and diversified set of problems, thus a need for extensible data-type system was felt.
By extensible it is meant that apart from using the built-in data types of a language, programmers can use these types to create their own data types such data types.
Some major categories of data types include:
Binary and Decimal Integers: (Converted into a bit string where the left most bit represents the sign of number).
Real Numbers: (In a 32-bit space, 24-bits represent the coefficient and 8 bit represent exponent)
Character Strings: (Also converted into bit strings but by means of encoding a specific bit-string is associated with a character. An eight bit binary sequence is capable of representing 255 characters)
Abstract Data Types (ADTs)
As mentioned above that a data type is a set of values and relevant operations. The collection of values and operations form a mathematical construct or represent a mathematical concept that may be implemented using a particular hardware or software data structure. The term “abstract data type” refers to the basic mathematical concept that defines the data type. The definition of ADT is not concerned with implementation details
Variable: variable is something whose value does not remain same. In order to ensure that machine understands the program correctly, a programmer must specify the data type of a variable.
Variables and Computers Memory: whatever value is assigned to a variable, it is converted into a bit string and stored into memory. By bit string we mean a series of “1s” and “0s”. (i.e. data is converted into binary). The computer’s memory is actually only capable of holding one of two values i.e. “1” which means “ON” (“presence of specific voltage”) and 0 which means OFF (“absence of specific voltage”)
Variable Declaration:
The statement that creates a variable is known as declaration. Declaration includes the data type and name of variable. Following is an example of declaration
int a;
The above statement communicates that “a” should have the data type “int”. i.e. it is capable of storing the range of data supported by “int” and all the operations of “int” can be applied on “a”. This statement will also cause memory to be allocated which will be referred by the variable “a”. Each memory location will have an address.
Address Operator can be used to retrieve the address of particular variable. e.g. “&a” will retrieve address of “a”
Pointers and Pointer Variable:
The address of a particular variable is often known as pointer and variables that hold the address of a pointer are known as pointer variable

INTRO ABOUT Data Structure: & Data Type:

Data Structure:
A data structure is a construct within a programming language that stores a collection of data.
Before moving ahead a number of concepts must be understood
Data Type:
A data type is composed of two things
Range of possible values
• Set of operations that can be performed on data.

Initially languages provided a non-extensible data type system. But as the benefits of software technology became clear, people started to apply technology to solve complex and diversified set of problems, thus a need for extensible data-type system was felt.
By extensible it is meant that apart from using the built-in data types of a language, programmers can use these types to create their own data types such data types.