Array
Upcoming SlideShare
Loading in...5
×
 

Array

Array

Statistics

Views

Total Views
258
Views on SlideShare
258
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Array Array Presentation Transcript

  • 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
  • ARRAYS Shafeeque shafeequemonp@gmail.com www.facebook.com/shafeeque monp pambodan twitter.com/shafeequemonp in.linkedin.com/in/shafeequem onp 9809611325
  • 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…?
  • 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’.
  • Array categories: Array One-dimensional array Syntax: Datatype arrayname[size]; Eg: Int a[10]; Multi-Dimensional array Syntax:Datatype arrayname[size of row] [size of column] Eg:int a[3][3];
  • 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:
  • 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‟
  • Multi-Dimensional Arrays… • Multi-Dimensional arrays – Tables with rows and columns – Like matrices: specify row, then column Row 0 Row 1 Row 2 Column 0 Column 1 Column 2 Column 3 a[ 0 ][ 0 ] a[ 1 ][ 0 ] a[ 2 ][ 0 ] a[ 0 ][ 1 ] a[ 1 ][ 1 ] a[ 2 ][ 1 ] a[ 0 ][ 2 ] a[ 1 ][ 2 ] a[ 2 ][ 2 ] a[ 0 ][ 3 ] a[ 1 ][ 3 ] a[ 2 ][ 3 ] Row subscript Array name Column subscript
  • • 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
  • 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
  • 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