2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
4. Variables
Variables are memory locations that are given names and
can be assigned values
For eg: int a=10;
Char b=‘string’;
A single value can be represented at a time by a single
identifier
If we want to represent multiple values
through a single identifier then…?
5. Arrays
Array by definition is a variable that hold multiple
elements which has the same data type
Group of consecutive memory locations
The various locations where the values can be
stored are called indexes
The various values stored on the indexes are
called the elements or the contents
Arrays are generally shown either in the form of rows or
in the form of columns
Syntax: Data type array name[size];
Eg: int a[10]; Indicates array ‘a’ of ‘int’type
of size ‘10’.
7. Declaring Arrays…
• When declaring arrays, specify
– Name
– Type of array
– Number of elements
arrayType arrayName[ numberOfElements ];
– Examples:
int c[ 10 ];
float myArray[ 3284 ];
• Declaring multiple arrays of same type
– Format similar to regular variables
– Example:
int b[ 100 ], x[ 27 ];
One-dimensional array:
8. Character arrays…
String “first” is really a static array of characters
Character arrays can be initialized using string literals
char string1[] = "first";
Null character '0' terminates strings
string1 actually has 6 elements
It is equivalent to
char string1[] = { 'f', 'i', 'r', 's', 't', '0'
};
Can access individual characters
string1[ 3 ] is character „s‟
10. • Initialization
– int b[ 2 ][ 2 ] = { { 1, 2 }, { 3, 4 } };
– Initializers grouped by row in braces
– If not enough, unspecified elements set to zero
int b[ 2 ][ 2 ] = { { 1 }, { 3, 4 } };
• Referencing elements
– Specify row, then column
printf( "%d", b[ 0 ][ 1 ] );
Multi_Dimensional Array..
1 2
3 4
1 0
3 4
11. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
12. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com