SlideShare a Scribd company logo
1
 Group Members
 RaviKumar A. Gelani (150120116020)
 Jay M. Chovatiya (150120116011)
 Jayraj M.Dabhi (150120116012)
Arrays
3
What is Array?
 An array is a fixed-size sequential collection of
elements of same data types that share a
common name.
 It is simply a group of data types.
 An array is a derived data type.
 An array is used to represent a list of numbers ,
or a list of names.
4
Example of Arrays:
 For Example :
1. List of employees in an organization.
2. Test scores of a class of students.
3. List of customers and their telephone numbers.
4. List of students in the college.
 For Example, to represent 100 students in college , can
be written as
student [100]
 Here student is a array name and [100] is called index
or subscript.
5
Types of Arrays
 Types of Array :
1. One-dimensional arrays
2. Two-dimensional arrays
3. Multidimensional arrays
6
One-dimensional Arrays.
 A variable which represent the list of items using only one
index (subscript) is called one-dimensional array.
 For Example , if we want to represent a set of five numbers
say(35,40,20,57,19), by an array variable number, then
number is declared as follows
int number [5] ;
7
One-dimensional Arrays.
 and the computer store these numbers as shown below :
number [0]
number [1]
number [2]
number [3]
number [4]
 The values can be assigned to the array as follows :
number [0] = 35;
number [1] = 40;
number [2] = 20;
number [3] = 57;
number [4] = 19;
8
DECLARATION OF ONE-DIMENSIONAL ARRAYS :
 The general form of array declaration is :
type array-name[size];
 Here the type specifies the data type of elements
contained in the array, such as int, float, or char.
 And the size indicates the maximum numbers of elements
that can be stored inside the array.
 The size should be either a numeric constant or a symbolic
constant.
9
Example
 For example :
int group [10] ;
 here int is type, group is a variable name , 10 is a size of
array and the subscripts (index) is start from 0 to 9.
10
INITIALIZATION OF ONE-DIMENSIONAL ARRAYS :
 An array can be stored in following stages :
1. At compile time
2. At run time
Compile time initialization :
 In compile time initialization, the array is initialized when
they are declared.
 The general form of initialization of array is :
type array-name[size] = { list of values };
 The list of values are separated by commas.
11
Compile time initialization
Example :
int number[3] = {4,5,9};
 Here array number of size 3 and will assign 4 to first
element(number[0]), 5 is assign with second
element(number[1]) and 9 is assign with third
element(number[2]).
 If the number of values in the list is less than the number of
elements, then only that many elements will be intialized. The
remaining elements will be set to zero automatically.
Compile time initialization
Example :
int number[ ] = {1,2,3,4};
 The character array can be initialized as follows :
char name[ ] = {‘j’,’o’,’h’,’n’,’0’};
 The character array can also be initialized as follows :
char name[ ] = “john”;
12
13
Run time initialization :
 In run time initialization, the array is explicitly initialize at run
time.
 This concept generally used for initializing large arrays.
 Example:
for(i=0; i < 100; i++)
{
if( i < 50)
sum[i] = 0.0;
else
sum[i] = 1.0;
}
 Here first 50 elements of the array sum are initialized to 0
and the remaining 50 elements are initialized to 1 at run
time.
14
Two-dimensional Arrays
 A variable which represent the list of items using two index
(subscript) is called two-dimensional array.
 In Two dimensional arrays, the data is stored in rows and
columns format.
 For example:
int table[2][3];
15
DECLARATION OF TWO-DIMENSIONAL ARRAYS :
 The general form of two dimensional array declaration is :
type array-name[row_size][column_size];
 Here the type specifies the data type of elements
contained in the array, such as int, float, or char.
 The size should be either a numeric constant or a
symbolic constant.
16
INITIALIZATION OF TWO-DIMENSIONAL ARRAYS :
 The general form of initializing two-dimensional array is :
type array-name[row_size][column_size] = {list
of values};
 Example :
int table[2][3] = {0,0,0,1,1,1};
 Here the elements of first row initializes to zero and the
elements of second row initializes to one.
 This above statement can be written as :
int table[2][3] = {{0,0,0}, {1,1,1}};
 In two-dimensional array the row_size can be omitted.
17
INITIALIZATION OF TWO-DIMENSIONAL ARRAYS :
 Example :
int table[ ][3] = {{0,0,0}, {1,1,1}};
 If the values are missing in an initializer, they are
automatically set to zero.
 Example :
int table[2][3] = {1,1,2};
 Here first row initialize to 1,1 and 2, and second row
initialize to 0,0 and 0 automatically.
18
Memory Layout of Two-dimensional array :
 In Two dimensional arrays, the data is stored in rows and
columns format.
 For example:
int table[2][3] = {1,2,3,4,5,6};
 The memory layout of above example :
table[0][0] = 1;
table[0][1] = 2
table[0][2] = 3;
table[1][0] = 4;
table[1][1] = 5;
table[1][2] = 6;
19
multi-dimensional Arrays
 A variable which represent the list of items using more than
two index (subscript) is called multi-dimensional array.
 The general form of multi dimensional array is :
type array-name[s1][s2][s3]…….[sn];
multi-dimensional Arrays
 Where S is the size. Some examples are :
int survey[3][5][6];
float table[5][4][5][3];
 Here survey is a three-dimensional array And table is a
four-dimensional array.
20
21
Applications Of arrays
 Using pointers for accessing arrays.
 Passing arrays as function parameters.
 Arrays as members of structures.
 Using structure type data as array elements.
 Arrays as dynamic data structures.
 Manipulating character arrays and strings.
THANK YOU

More Related Content

What's hot

class and objects
class and objectsclass and objects
class and objects
Payel Guria
 

What's hot (20)

RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
Array in c++
Array in c++Array in c++
Array in c++
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
class and objects
class and objectsclass and objects
class and objects
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Arrays
ArraysArrays
Arrays
 
Function in C program
Function in C programFunction in C program
Function in C program
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
2D Array
2D Array 2D Array
2D Array
 

Similar to Array in c

BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 

Similar to Array in c (20)

Arrays in c
Arrays in cArrays in c
Arrays in c
 
lec 2- array declaration and initialization.pptx
lec 2- array declaration and initialization.pptxlec 2- array declaration and initialization.pptx
lec 2- array declaration and initialization.pptx
 
array-160309152651.pptx
array-160309152651.pptxarray-160309152651.pptx
array-160309152651.pptx
 
Arrays
ArraysArrays
Arrays
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Array
ArrayArray
Array
 
Array
ArrayArray
Array
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
 
Algo>Arrays
Algo>ArraysAlgo>Arrays
Algo>Arrays
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
 
Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional
 
ARRAYS
ARRAYSARRAYS
ARRAYS
 
Chap 7(array)
Chap 7(array)Chap 7(array)
Chap 7(array)
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Comp102 lec 8
Comp102   lec 8Comp102   lec 8
Comp102 lec 8
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Array in C full basic explanation
Array in C full basic explanationArray in C full basic explanation
Array in C full basic explanation
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 

More from Ravi Gelani (14)

oep eg
oep egoep eg
oep eg
 
Eg oep
Eg oepEg oep
Eg oep
 
Cpd resume
Cpd resumeCpd resume
Cpd resume
 
Vector Spaces,subspaces,Span,Basis
Vector Spaces,subspaces,Span,BasisVector Spaces,subspaces,Span,Basis
Vector Spaces,subspaces,Span,Basis
 
Air compresser by Ravi Gelani
Air compresser by Ravi GelaniAir compresser by Ravi Gelani
Air compresser by Ravi Gelani
 
to recognize static and dynamic identity
to recognize static and dynamic identityto recognize static and dynamic identity
to recognize static and dynamic identity
 
Air compressors
Air compressorsAir compressors
Air compressors
 
projection of line
projection of lineprojection of line
projection of line
 
Modulaing Techniquies
Modulaing TechniquiesModulaing Techniquies
Modulaing Techniquies
 
demonstrate trust behaviour
demonstrate trust behaviourdemonstrate trust behaviour
demonstrate trust behaviour
 
Introduction of Indeterminate Form
Introduction  of Indeterminate FormIntroduction  of Indeterminate Form
Introduction of Indeterminate Form
 
preparing presentation
preparing presentationpreparing presentation
preparing presentation
 
Laser in physics
Laser in physicsLaser in physics
Laser in physics
 
Power factor and power in AC circuit
Power factor and power in AC circuitPower factor and power in AC circuit
Power factor and power in AC circuit
 

Recently uploaded

Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdfDanfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 

Array in c

  • 1. 1  Group Members  RaviKumar A. Gelani (150120116020)  Jay M. Chovatiya (150120116011)  Jayraj M.Dabhi (150120116012)
  • 3. 3 What is Array?  An array is a fixed-size sequential collection of elements of same data types that share a common name.  It is simply a group of data types.  An array is a derived data type.  An array is used to represent a list of numbers , or a list of names.
  • 4. 4 Example of Arrays:  For Example : 1. List of employees in an organization. 2. Test scores of a class of students. 3. List of customers and their telephone numbers. 4. List of students in the college.  For Example, to represent 100 students in college , can be written as student [100]  Here student is a array name and [100] is called index or subscript.
  • 5. 5 Types of Arrays  Types of Array : 1. One-dimensional arrays 2. Two-dimensional arrays 3. Multidimensional arrays
  • 6. 6 One-dimensional Arrays.  A variable which represent the list of items using only one index (subscript) is called one-dimensional array.  For Example , if we want to represent a set of five numbers say(35,40,20,57,19), by an array variable number, then number is declared as follows int number [5] ;
  • 7. 7 One-dimensional Arrays.  and the computer store these numbers as shown below : number [0] number [1] number [2] number [3] number [4]  The values can be assigned to the array as follows : number [0] = 35; number [1] = 40; number [2] = 20; number [3] = 57; number [4] = 19;
  • 8. 8 DECLARATION OF ONE-DIMENSIONAL ARRAYS :  The general form of array declaration is : type array-name[size];  Here the type specifies the data type of elements contained in the array, such as int, float, or char.  And the size indicates the maximum numbers of elements that can be stored inside the array.  The size should be either a numeric constant or a symbolic constant.
  • 9. 9 Example  For example : int group [10] ;  here int is type, group is a variable name , 10 is a size of array and the subscripts (index) is start from 0 to 9.
  • 10. 10 INITIALIZATION OF ONE-DIMENSIONAL ARRAYS :  An array can be stored in following stages : 1. At compile time 2. At run time Compile time initialization :  In compile time initialization, the array is initialized when they are declared.  The general form of initialization of array is : type array-name[size] = { list of values };  The list of values are separated by commas.
  • 11. 11 Compile time initialization Example : int number[3] = {4,5,9};  Here array number of size 3 and will assign 4 to first element(number[0]), 5 is assign with second element(number[1]) and 9 is assign with third element(number[2]).  If the number of values in the list is less than the number of elements, then only that many elements will be intialized. The remaining elements will be set to zero automatically.
  • 12. Compile time initialization Example : int number[ ] = {1,2,3,4};  The character array can be initialized as follows : char name[ ] = {‘j’,’o’,’h’,’n’,’0’};  The character array can also be initialized as follows : char name[ ] = “john”; 12
  • 13. 13 Run time initialization :  In run time initialization, the array is explicitly initialize at run time.  This concept generally used for initializing large arrays.  Example: for(i=0; i < 100; i++) { if( i < 50) sum[i] = 0.0; else sum[i] = 1.0; }  Here first 50 elements of the array sum are initialized to 0 and the remaining 50 elements are initialized to 1 at run time.
  • 14. 14 Two-dimensional Arrays  A variable which represent the list of items using two index (subscript) is called two-dimensional array.  In Two dimensional arrays, the data is stored in rows and columns format.  For example: int table[2][3];
  • 15. 15 DECLARATION OF TWO-DIMENSIONAL ARRAYS :  The general form of two dimensional array declaration is : type array-name[row_size][column_size];  Here the type specifies the data type of elements contained in the array, such as int, float, or char.  The size should be either a numeric constant or a symbolic constant.
  • 16. 16 INITIALIZATION OF TWO-DIMENSIONAL ARRAYS :  The general form of initializing two-dimensional array is : type array-name[row_size][column_size] = {list of values};  Example : int table[2][3] = {0,0,0,1,1,1};  Here the elements of first row initializes to zero and the elements of second row initializes to one.  This above statement can be written as : int table[2][3] = {{0,0,0}, {1,1,1}};  In two-dimensional array the row_size can be omitted.
  • 17. 17 INITIALIZATION OF TWO-DIMENSIONAL ARRAYS :  Example : int table[ ][3] = {{0,0,0}, {1,1,1}};  If the values are missing in an initializer, they are automatically set to zero.  Example : int table[2][3] = {1,1,2};  Here first row initialize to 1,1 and 2, and second row initialize to 0,0 and 0 automatically.
  • 18. 18 Memory Layout of Two-dimensional array :  In Two dimensional arrays, the data is stored in rows and columns format.  For example: int table[2][3] = {1,2,3,4,5,6};  The memory layout of above example : table[0][0] = 1; table[0][1] = 2 table[0][2] = 3; table[1][0] = 4; table[1][1] = 5; table[1][2] = 6;
  • 19. 19 multi-dimensional Arrays  A variable which represent the list of items using more than two index (subscript) is called multi-dimensional array.  The general form of multi dimensional array is : type array-name[s1][s2][s3]…….[sn];
  • 20. multi-dimensional Arrays  Where S is the size. Some examples are : int survey[3][5][6]; float table[5][4][5][3];  Here survey is a three-dimensional array And table is a four-dimensional array. 20
  • 21. 21 Applications Of arrays  Using pointers for accessing arrays.  Passing arrays as function parameters.  Arrays as members of structures.  Using structure type data as array elements.  Arrays as dynamic data structures.  Manipulating character arrays and strings.