SlideShare a Scribd company logo
WELCOME
Rababa Kareem Kollathodi,
Assistant Professor,
Sscollege, Areekode.
Types of Array
● Linear Array
● Non-Linear Array
Linear Array
This type of array is also called one Dimensional Array. This is also called list array. Another name of linear array is
called single-dimensional array. These array are of ladder type. In the linear array only one subscript is used. It is written either in row
or in column form.
The syntax to define or declare linear array is:
data-type arrary-name[size];
Basic Array Operations
Following are the basic operations supported by an array.
● Traverse − print all the array elements one by one.
● Insertion − Adds an element at the given index.
● Deletion − Deletes an element at the given index.
● Search − Searches an element using the given index or by the value.
Traverse Operation
This operation is to traverse through the elements of an array.
Example: Following program traverses and prints the elements of an array:
#include <stdio.h>
main() {
int LA[] = {1,3,5,7,8};
int n = 5;
int i;
printf("The original array elements are :n");
for(i = 0; i<n; i++) {
printf("LA[%d] = %d n", i, LA[i]); }
}
When we compile and execute the above program, it produces the following result :
The original array elements are :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
Insertion Operation
Insert operation is to insert one or more data elements into an array. Based on the requirement, a new element can be
added at the beginning, end, or any given index of array.
Insertion at the end of an Array:
#include <stdio.h>
#define MAX 5
void main() {
int array[MAX] = {1, 2, 3, 4};
int N = 4, i = 0, value = 5;
printf("Printing array before insertion −n");
for(i = 0; i < N; i++)
printf("array[%d] = %d n", i, array[i]);
array[N] = value;
N++;
printf("Printing array after insertion −n");
for(i = 0; i < N; i++)
printf("array[%d] = %dn", i, array[i]);
}
Output
Printing array before insertion −
array[0] = 1
array[1] = 2
array[2] = 3
array[3] = 4
Printing array after insertion −
array[0] = 1
array[1] = 2
array[2] = 3
array[3] = 4
array[4] = 5
Non-Linear Array
Array of having different dimensions or n subscript is in the form of Non-linear array. Non-linear array are further of n
different types as:
(a) Two Dimensional Array
(b) Three Dimensional Array
............................
(n) N-Dimensional Array
Two-Dimensional Array
These arrays are also called double dimensional array. Another name of two-dimensional array is Tabular or
Rectangular Array. These array are in row and column form, so these are also called Row-Column array or square array.
The syntax to define or declare two dimensional array is as:
data-type arrary-name[row size][column size];
For example, some of the valid one dimensional array declaration statements are written as below:
int a[10][10];
float f[50][50];
char n[20][20];
Three-Dimensional Array
Initializing Three-Dimensional Array: Initialization in Three-Dimensional array is same as that of Two-dimensional arrays.
The difference is as the number of dimension increases so the number of nested braces will also increase.
Method 1:
int x[2][3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23};
Better Method:
int x[2][3][4] = {
{ {0,1,2,3}, {4,5,6,7}, {8,9,10,11} },
{ {12,13,14,15}, {16,17,18,19}, {20,21,22,23} }
};
Thank You

More Related Content

What's hot

Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
Awais Alam
 
Array
ArrayArray
Arrays
ArraysArrays
Arrays In C
Arrays In CArrays In C
Arrays In C
yndaravind
 
Array in Java
Array in JavaArray in Java
Array in Java
Ali shah
 
Array in (C) programing
Array in (C) programing Array in (C) programing
Array in (C) programing
mJafarww
 
Java arrays
Java arraysJava arrays
Java arrays
Jin Castor
 
Radix sort
Radix sortRadix sort
Radix sort
zahraa F.Muhsen
 
Array in Java
Array in JavaArray in Java
Array in Java
Ali shah
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
Subhasis Nayak
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
Arzath Areeff
 
Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]
Muhammad Hammad Waseem
 
Arrays
ArraysArrays
Java Arrays
Java ArraysJava Arrays
Java Arrays
OXUS 20
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Array in c
Array in cArray in c
Array in c
AnIsh Kumar
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arrays
Satyam Soni
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
Michael Heron
 

What's hot (20)

Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Array in (C) programing
Array in (C) programing Array in (C) programing
Array in (C) programing
 
Java arrays
Java arraysJava arrays
Java arrays
 
Radix sort
Radix sortRadix sort
Radix sort
 
Array in Java
Array in JavaArray in Java
Array in Java
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]
 
Arrays
ArraysArrays
Arrays
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Array in c
Array in cArray in c
Array in c
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Array in c
Array in cArray in c
Array in c
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arrays
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 

Similar to Arrays

C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
HimanshuKansal22
 
presentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.pptpresentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.ppt
NamakkalPasanga
 
Arrays
ArraysArrays
Python array
Python arrayPython array
Python array
Arnab Chakraborty
 
Arrays
ArraysArrays
Arrays
Aman Agarwal
 
Array
ArrayArray
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Array
ArrayArray
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdf
saneshgamerz
 
Array
ArrayArray
1D Array
1D Array1D Array
1D Array
A. S. M. Shafi
 
Array
ArrayArray
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
Dhiviya Rose
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
11STEM2PGROUP1
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptx
DarellMuchoko
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
NehaJain919374
 
Array
ArrayArray
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 

Similar to Arrays (20)

C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
presentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.pptpresentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.ppt
 
Arrays
ArraysArrays
Arrays
 
Python array
Python arrayPython array
Python array
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
 
Array
ArrayArray
Array
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdf
 
Array
ArrayArray
Array
 
1D Array
1D Array1D Array
1D Array
 
Array
ArrayArray
Array
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptx
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Array
ArrayArray
Array
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 

Recently uploaded

What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 

Recently uploaded (20)

What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 

Arrays

  • 1. WELCOME Rababa Kareem Kollathodi, Assistant Professor, Sscollege, Areekode.
  • 2. Types of Array ● Linear Array ● Non-Linear Array Linear Array This type of array is also called one Dimensional Array. This is also called list array. Another name of linear array is called single-dimensional array. These array are of ladder type. In the linear array only one subscript is used. It is written either in row or in column form. The syntax to define or declare linear array is: data-type arrary-name[size];
  • 3. Basic Array Operations Following are the basic operations supported by an array. ● Traverse − print all the array elements one by one. ● Insertion − Adds an element at the given index. ● Deletion − Deletes an element at the given index. ● Search − Searches an element using the given index or by the value.
  • 4. Traverse Operation This operation is to traverse through the elements of an array. Example: Following program traverses and prints the elements of an array: #include <stdio.h> main() { int LA[] = {1,3,5,7,8}; int n = 5; int i; printf("The original array elements are :n"); for(i = 0; i<n; i++) { printf("LA[%d] = %d n", i, LA[i]); } }
  • 5. When we compile and execute the above program, it produces the following result : The original array elements are : LA[0] = 1 LA[1] = 3 LA[2] = 5 LA[3] = 7 LA[4] = 8 Insertion Operation Insert operation is to insert one or more data elements into an array. Based on the requirement, a new element can be added at the beginning, end, or any given index of array.
  • 6. Insertion at the end of an Array: #include <stdio.h> #define MAX 5 void main() { int array[MAX] = {1, 2, 3, 4}; int N = 4, i = 0, value = 5; printf("Printing array before insertion −n"); for(i = 0; i < N; i++) printf("array[%d] = %d n", i, array[i]); array[N] = value; N++; printf("Printing array after insertion −n"); for(i = 0; i < N; i++) printf("array[%d] = %dn", i, array[i]); }
  • 7. Output Printing array before insertion − array[0] = 1 array[1] = 2 array[2] = 3 array[3] = 4 Printing array after insertion − array[0] = 1 array[1] = 2 array[2] = 3 array[3] = 4 array[4] = 5
  • 8. Non-Linear Array Array of having different dimensions or n subscript is in the form of Non-linear array. Non-linear array are further of n different types as: (a) Two Dimensional Array (b) Three Dimensional Array ............................ (n) N-Dimensional Array
  • 9. Two-Dimensional Array These arrays are also called double dimensional array. Another name of two-dimensional array is Tabular or Rectangular Array. These array are in row and column form, so these are also called Row-Column array or square array. The syntax to define or declare two dimensional array is as: data-type arrary-name[row size][column size]; For example, some of the valid one dimensional array declaration statements are written as below: int a[10][10]; float f[50][50]; char n[20][20];
  • 11. Initializing Three-Dimensional Array: Initialization in Three-Dimensional array is same as that of Two-dimensional arrays. The difference is as the number of dimension increases so the number of nested braces will also increase. Method 1: int x[2][3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}; Better Method: int x[2][3][4] = { { {0,1,2,3}, {4,5,6,7}, {8,9,10,11} }, { {12,13,14,15}, {16,17,18,19}, {20,21,22,23} } };