SlideShare a Scribd company logo
GANDHINAGAR INSTITUTE OF
TECHONOLOGY(012)
SUBJECT : Computer Programming and
Utilization(2110003)
Active Learning Assignment on the topic of
“Concepts of Arrays,
One dimensional array declaration and initialization”
BE Mechanical
Prepared By:
03-02-2018 1
Prepared by-
Guided by –
Gandhinagar Institute of Technology
SUBJECT: CPU (2110003)
“Concepts of Arrays,
One dimensional array declaration and initialization”
CONTAIN
• Introduction
• Types of Arrays
• Declaration of 1D Arrays
• Initialization of 1D Arrays
• Reference
203-02-2018
Introduction
3
 We have used the fundamental data types, char,int, float,
double.
 These types are constrained by the fact that a variable of these
types can store only one value at any given time.
 In many applications, we need to handle large volumes of data.
 To process such large amounts of data, we need a powerful
data types that would facilitate efficient storing, accessing and
manipulation of data items.
03-02-2018
Introduction
4
 C supports a derived data type known as array.
 An array is a fixed-size sequenced collection of
elements of the same data type.
 An array can be used to represent a list of numbers, or
a list of names.
 Example: List of temperatures recorded in every hour
in a day, or a month, or a year.
03-02-2018
Types of Arrays
5
Array can be classified as following types…
1) One Dimensional arrays
2) Two Dimensional arrays
3) Maltidimensional arrays
03-02-2018
One-Dimensional Arrays
6
 Dimensional refers to the array’s size , which is how big the
array is.
A list of item can be given one variable name using only one
subscript and such a variable is called One Dimensional Arrays.
 A one-dimensional array can be used to represent a list of data
items.
 It is also known as a vector.
03-02-2018
Declaration of 1D Arrays
7
 Every array must be declared before use like other variables.
 The general form of array declaration is ….
datatype variable-name [size];
datatype refers to the data type of elements in the array. It can
be int, char, float, long int etc.
Name is an identifier which represents the array name.
Size is an integer expression representing the total number of
elements in the array.
Where,
03-02-2018
Declaration of 1D Arrays
8
Example:
1) int list[10];
2) char name[20];
3) float height[30];
 When an array is declared, the compiler allocates a base
address and reserves enough space in memory for all
the elements of the array.
 In C, the array name represents this base address.
 For example: float x[5]; is the declaration of a one-
dimensional array.
03-02-2018
Initialization of 1D Arrays
9
 An array can be initialised in its declaration only.
 After an array is declared, its elements must be initialized.
Otherwise, they will contain “garbage”.
 An array can be initialized at either of the following
stages:
 At compile time
 At run time
 The general form of initilization of arrays is ….
datatype array-name [size]= {list of values};
03-02-2018
Initialization of 1D Arrays
10
 The list of values are enclosed in bracets.
 The initialisers are separated by commas and they must be
constants or constant expressions.
 A semicolon should be placed after the closing bracet.
One-dimensional array can be initialised as given below:
int a[4]={3,5,-8, 10};
The values within the bracets are scanned from left end and
assigned to a[0], a[1] and so on.
 The size of a one-dimensional array need not be mentioned in its
initialisation.
 In this case, the compiler will count the values assigned and take it
as the size of that array.
03-02-2018
Reference
11
 Tata Mc Graw Hill Education
(E Balagurusamy)
03-02-2018
Thank You

More Related Content

What's hot

Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
St Mary's College,Thrissur,Kerala
 
Data structure
Data structureData structure
Data structureMohd Arif
 
Pooja
PoojaPooja
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked lists
Deepam Aggarwal
 
7.basic array
7.basic array7.basic array
7.basic array
Mir Riyanul Islam
 
Slide 1.-datastructure
Slide 1.-datastructureSlide 1.-datastructure
Slide 1.-datastructure
Minhaz Leo
 
Array
ArrayArray
Data Applied: Clustering
Data Applied: ClusteringData Applied: Clustering
Data Applied: Clustering
DataminingTools Inc
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Abbott
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Quick dive to pandas
Quick dive to pandasQuick dive to pandas
Quick dive to pandas
Robin Kiplangat
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. Array
AndiNurkholis1
 
2 introduction to data structure
2  introduction to data structure2  introduction to data structure
2 introduction to data structure
Mahmoud Alfarra
 
Data structure Assignment Help
Data structure Assignment HelpData structure Assignment Help
Data structure Assignment Help
JosephErin
 
Arrays introduction- JAVA
Arrays introduction- JAVAArrays introduction- JAVA
Arrays introduction- JAVAHamna_sheikh
 

What's hot (19)

Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
Data structure
Data structureData structure
Data structure
 
Algo>Abstract data type
Algo>Abstract data typeAlgo>Abstract data type
Algo>Abstract data type
 
Pooja
PoojaPooja
Pooja
 
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked lists
 
7.basic array
7.basic array7.basic array
7.basic array
 
Slide 1.-datastructure
Slide 1.-datastructureSlide 1.-datastructure
Slide 1.-datastructure
 
Array
ArrayArray
Array
 
Data Applied: Clustering
Data Applied: ClusteringData Applied: Clustering
Data Applied: Clustering
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Quick dive to pandas
Quick dive to pandasQuick dive to pandas
Quick dive to pandas
 
Lec3
Lec3Lec3
Lec3
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. Array
 
2 introduction to data structure
2  introduction to data structure2  introduction to data structure
2 introduction to data structure
 
Data structure Assignment Help
Data structure Assignment HelpData structure Assignment Help
Data structure Assignment Help
 
Arrays introduction- JAVA
Arrays introduction- JAVAArrays introduction- JAVA
Arrays introduction- JAVA
 

Similar to Concepts of Arrays

Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
KirubelWondwoson1
 
Arrays
ArraysArrays
Arrays
ViniVini48
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
Surbhi Yadav
 
Arrays in c_language
Arrays in c_language Arrays in c_language
Arrays in c_language
Infinity Tech Solutions
 
Data-Structure-original-QuantumSupply.pdf
Data-Structure-original-QuantumSupply.pdfData-Structure-original-QuantumSupply.pdf
Data-Structure-original-QuantumSupply.pdf
lehal93146
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
HNDE Labuduwa Galle
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
Shubham Sharma
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
arshpreetkaur07
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
nmahi96
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
Munazza-Mah-Jabeen
 
Array
ArrayArray
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
heena94
 
Arrays In C
Arrays In CArrays In C
Arrays In C
yndaravind
 

Similar to Concepts of Arrays (20)

arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
 
Arrays
ArraysArrays
Arrays
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
 
Unit 2
Unit 2Unit 2
Unit 2
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Arrays in c_language
Arrays in c_language Arrays in c_language
Arrays in c_language
 
Data-Structure-original-QuantumSupply.pdf
Data-Structure-original-QuantumSupply.pdfData-Structure-original-QuantumSupply.pdf
Data-Structure-original-QuantumSupply.pdf
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
10 array
10 array10 array
10 array
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
Array
ArrayArray
Array
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 

More from Yashh Pandya

Laser beam machining
Laser beam machiningLaser beam machining
Laser beam machining
Yashh Pandya
 
Air conditining system
Air conditining systemAir conditining system
Air conditining system
Yashh Pandya
 
Complex Numbers & Functions
Complex Numbers & FunctionsComplex Numbers & Functions
Complex Numbers & Functions
Yashh Pandya
 
Powder Metallurgy
Powder MetallurgyPowder Metallurgy
Powder Metallurgy
Yashh Pandya
 
Planer & Slotter
Planer & SlotterPlaner & Slotter
Planer & Slotter
Yashh Pandya
 
Friction
FrictionFriction
Friction
Yashh Pandya
 
Synthesis of Mechanisms
Synthesis of MechanismsSynthesis of Mechanisms
Synthesis of Mechanisms
Yashh Pandya
 
Analytic Function of Power Series
Analytic Function of Power Series Analytic Function of Power Series
Analytic Function of Power Series
Yashh Pandya
 
Inverse of a Matrix
Inverse of a MatrixInverse of a Matrix
Inverse of a Matrix
Yashh Pandya
 
Introduction to Nano-materials
Introduction to Nano-materials Introduction to Nano-materials
Introduction to Nano-materials
Yashh Pandya
 
illumination scheme
illumination scheme illumination scheme
illumination scheme
Yashh Pandya
 
The Road Not Taken by Robert Frost
The Road Not Taken by Robert FrostThe Road Not Taken by Robert Frost
The Road Not Taken by Robert Frost
Yashh Pandya
 
Embarking journey to contributership
Embarking journey to contributership Embarking journey to contributership
Embarking journey to contributership
Yashh Pandya
 
Refrigeration
RefrigerationRefrigeration
Refrigeration
Yashh Pandya
 
Projection of solid
Projection of solid Projection of solid
Projection of solid
Yashh Pandya
 
Forest Resources
Forest ResourcesForest Resources
Forest Resources
Yashh Pandya
 
Traffic control Devices
Traffic control DevicesTraffic control Devices
Traffic control Devices
Yashh Pandya
 
Power series and radius of convergence
Power series and radius of convergencePower series and radius of convergence
Power series and radius of convergence
Yashh Pandya
 

More from Yashh Pandya (18)

Laser beam machining
Laser beam machiningLaser beam machining
Laser beam machining
 
Air conditining system
Air conditining systemAir conditining system
Air conditining system
 
Complex Numbers & Functions
Complex Numbers & FunctionsComplex Numbers & Functions
Complex Numbers & Functions
 
Powder Metallurgy
Powder MetallurgyPowder Metallurgy
Powder Metallurgy
 
Planer & Slotter
Planer & SlotterPlaner & Slotter
Planer & Slotter
 
Friction
FrictionFriction
Friction
 
Synthesis of Mechanisms
Synthesis of MechanismsSynthesis of Mechanisms
Synthesis of Mechanisms
 
Analytic Function of Power Series
Analytic Function of Power Series Analytic Function of Power Series
Analytic Function of Power Series
 
Inverse of a Matrix
Inverse of a MatrixInverse of a Matrix
Inverse of a Matrix
 
Introduction to Nano-materials
Introduction to Nano-materials Introduction to Nano-materials
Introduction to Nano-materials
 
illumination scheme
illumination scheme illumination scheme
illumination scheme
 
The Road Not Taken by Robert Frost
The Road Not Taken by Robert FrostThe Road Not Taken by Robert Frost
The Road Not Taken by Robert Frost
 
Embarking journey to contributership
Embarking journey to contributership Embarking journey to contributership
Embarking journey to contributership
 
Refrigeration
RefrigerationRefrigeration
Refrigeration
 
Projection of solid
Projection of solid Projection of solid
Projection of solid
 
Forest Resources
Forest ResourcesForest Resources
Forest Resources
 
Traffic control Devices
Traffic control DevicesTraffic control Devices
Traffic control Devices
 
Power series and radius of convergence
Power series and radius of convergencePower series and radius of convergence
Power series and radius of convergence
 

Concepts of Arrays

  • 1. GANDHINAGAR INSTITUTE OF TECHONOLOGY(012) SUBJECT : Computer Programming and Utilization(2110003) Active Learning Assignment on the topic of “Concepts of Arrays, One dimensional array declaration and initialization” BE Mechanical Prepared By: 03-02-2018 1
  • 2. Prepared by- Guided by – Gandhinagar Institute of Technology SUBJECT: CPU (2110003) “Concepts of Arrays, One dimensional array declaration and initialization”
  • 3. CONTAIN • Introduction • Types of Arrays • Declaration of 1D Arrays • Initialization of 1D Arrays • Reference 203-02-2018
  • 4. Introduction 3  We have used the fundamental data types, char,int, float, double.  These types are constrained by the fact that a variable of these types can store only one value at any given time.  In many applications, we need to handle large volumes of data.  To process such large amounts of data, we need a powerful data types that would facilitate efficient storing, accessing and manipulation of data items. 03-02-2018
  • 5. Introduction 4  C supports a derived data type known as array.  An array is a fixed-size sequenced collection of elements of the same data type.  An array can be used to represent a list of numbers, or a list of names.  Example: List of temperatures recorded in every hour in a day, or a month, or a year. 03-02-2018
  • 6. Types of Arrays 5 Array can be classified as following types… 1) One Dimensional arrays 2) Two Dimensional arrays 3) Maltidimensional arrays 03-02-2018
  • 7. One-Dimensional Arrays 6  Dimensional refers to the array’s size , which is how big the array is. A list of item can be given one variable name using only one subscript and such a variable is called One Dimensional Arrays.  A one-dimensional array can be used to represent a list of data items.  It is also known as a vector. 03-02-2018
  • 8. Declaration of 1D Arrays 7  Every array must be declared before use like other variables.  The general form of array declaration is …. datatype variable-name [size]; datatype refers to the data type of elements in the array. It can be int, char, float, long int etc. Name is an identifier which represents the array name. Size is an integer expression representing the total number of elements in the array. Where, 03-02-2018
  • 9. Declaration of 1D Arrays 8 Example: 1) int list[10]; 2) char name[20]; 3) float height[30];  When an array is declared, the compiler allocates a base address and reserves enough space in memory for all the elements of the array.  In C, the array name represents this base address.  For example: float x[5]; is the declaration of a one- dimensional array. 03-02-2018
  • 10. Initialization of 1D Arrays 9  An array can be initialised in its declaration only.  After an array is declared, its elements must be initialized. Otherwise, they will contain “garbage”.  An array can be initialized at either of the following stages:  At compile time  At run time  The general form of initilization of arrays is …. datatype array-name [size]= {list of values}; 03-02-2018
  • 11. Initialization of 1D Arrays 10  The list of values are enclosed in bracets.  The initialisers are separated by commas and they must be constants or constant expressions.  A semicolon should be placed after the closing bracet. One-dimensional array can be initialised as given below: int a[4]={3,5,-8, 10}; The values within the bracets are scanned from left end and assigned to a[0], a[1] and so on.  The size of a one-dimensional array need not be mentioned in its initialisation.  In this case, the compiler will count the values assigned and take it as the size of that array. 03-02-2018
  • 12. Reference 11  Tata Mc Graw Hill Education (E Balagurusamy) 03-02-2018