SlideShare a Scribd company logo
Arrays
What you’ll learn:
o Defining and using arrays
o Defining and using strings
What is an array ?
 An array is a collection of variables of the same type that are referenced by a common
name.
 They are a derived data type.
 We can divide arrays into two types:
 Single Dimensional (1-D) arrays
 Multi Dimensional arrays
Single Dimensional Arrays
1 2 3
int arr [5] = { 1, 2, 3, 4, 5 };
Syntax: base_type array_name [size];
Size
Array name Initialization
Base Type
Memory:
4000 4016 4020
4 5
4004
Total Size:
4 X 5 = 20
Multi Dimensional Arrays
1 2 3 4 5
int arr [3][2] = { {1,2}, {3,4}, {5,6} };
Syntax: base_type array_name [rows][columns];
Size
Array name Initialization
Base Type
Memory
4000 4020 4024
6
4004
Total Size:
4 X 6 = 24
1 2
3 4
5 6
4008
4016
4000
Strings
‘H’ ‘e’ ‘l’ ‘l’
char str[] = “Hello”;
Syntax: char array_name [size];
Size
String name Initialization
Memory:
4000 4005 4006
‘o’ ‘0’
4001
Total Size:
1 X 6 = 6

More Related Content

PPT
Presentation of array
PPTX
PPT
Numeric Arrays [6]
PPTX
Basic array in c programming
PPTX
Arrays in c
PPTX
Arrays In C Language
PPTX
Array in c
PPTX
A wonderful tutorial about an Array
Presentation of array
Numeric Arrays [6]
Basic array in c programming
Arrays in c
Arrays In C Language
Array in c
A wonderful tutorial about an Array

What's hot (20)

PPTX
Array in (C) programing
PDF
Arrays In C
PPTX
arrays of structures
PPTX
Array in c
PPTX
Array c programming
PPT
One Dimensional Array
PDF
Algorithm and Data Structure - Array and Struct
PPTX
Array in c++
PPTX
2 d array
PPTX
R data structures-2
PPTX
R Data Structures (Part 1)
PPTX
R data-structures-3
PPTX
#Jai c presentation
PDF
SPL 10 | One Dimensional Array in C
PPTX
Array,MULTI ARRAY, IN C
PPT
Unit4 C
PPTX
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
PPTX
Array,data type
Array in (C) programing
Arrays In C
arrays of structures
Array in c
Array c programming
One Dimensional Array
Algorithm and Data Structure - Array and Struct
Array in c++
2 d array
R data structures-2
R Data Structures (Part 1)
R data-structures-3
#Jai c presentation
SPL 10 | One Dimensional Array in C
Array,MULTI ARRAY, IN C
Unit4 C
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Array,data type
Ad

Viewers also liked (8)

PPTX
6.operators
PPTX
5.functions
PPTX
8.derived data types
PPTX
3.looping(iteration statements)
PPTX
2.decision making
PPTX
7.pointers
PPTX
1.getting started with c
PDF
Programming & Data Structure Lecture Notes
6.operators
5.functions
8.derived data types
3.looping(iteration statements)
2.decision making
7.pointers
1.getting started with c
Programming & Data Structure Lecture Notes
Ad

Similar to 4.arrays (20)

PPTX
Introduction to Array & Structure & Basic Algorithms.pptx
PPTX
PPT
Arrays
PPTX
Arrays in Data Structure and Algorithm
PPT
PPTX
Array , Structure and Basic Algorithms.pptx
PDF
Chapter 4 (Part I) - Array and Strings.pdf
PPTX
Array definition and uses in computer.pptx
PPTX
Introduction to Array ppt
PPTX
PPTX
ARRAY
PPTX
Arrays in c
PPT
Mesics lecture 8 arrays in 'c'
PPTX
BHARGAVIARRAY.PPT.pptx
PDF
Learn Java Part 9
PPT
Lecture 15 - Array
PPTX
Arrays.pptx
PPTX
Array lecture
PPTX
Introduction to Array & Structure & Basic Algorithms.pptx
Arrays
Arrays in Data Structure and Algorithm
Array , Structure and Basic Algorithms.pptx
Chapter 4 (Part I) - Array and Strings.pdf
Array definition and uses in computer.pptx
Introduction to Array ppt
ARRAY
Arrays in c
Mesics lecture 8 arrays in 'c'
BHARGAVIARRAY.PPT.pptx
Learn Java Part 9
Lecture 15 - Array
Arrays.pptx
Array lecture

4.arrays

  • 1. Arrays What you’ll learn: o Defining and using arrays o Defining and using strings
  • 2. What is an array ?  An array is a collection of variables of the same type that are referenced by a common name.  They are a derived data type.  We can divide arrays into two types:  Single Dimensional (1-D) arrays  Multi Dimensional arrays
  • 3. Single Dimensional Arrays 1 2 3 int arr [5] = { 1, 2, 3, 4, 5 }; Syntax: base_type array_name [size]; Size Array name Initialization Base Type Memory: 4000 4016 4020 4 5 4004 Total Size: 4 X 5 = 20
  • 4. Multi Dimensional Arrays 1 2 3 4 5 int arr [3][2] = { {1,2}, {3,4}, {5,6} }; Syntax: base_type array_name [rows][columns]; Size Array name Initialization Base Type Memory 4000 4020 4024 6 4004 Total Size: 4 X 6 = 24 1 2 3 4 5 6 4008 4016 4000
  • 5. Strings ‘H’ ‘e’ ‘l’ ‘l’ char str[] = “Hello”; Syntax: char array_name [size]; Size String name Initialization Memory: 4000 4005 4006 ‘o’ ‘0’ 4001 Total Size: 1 X 6 = 6

Editor's Notes