SlideShare a Scribd company logo
1 of 17
Session Objectives
Explain Declaration,Initialization of Array
Explain Types of Array
One Dimensional,Two Dimensional and Multi
Dimensional Array
Explain Arrays
Array is defined as a set of homogeneous data items.
An Array is a group of elements that share a common name
that are differentiated from one another by their positions within the
array
Datatype arrayname[subscript];
1) Arrayname should be a valid “C” variable
2) Arrayname should be unique
3) The elements in the array should be of same type
4) Subscript (array size) cannot be negative
5) Subscript must always be an integer
Single or One Dimensional Arrays
Arrays whose elements are specified by one subscript
are called One dimensional array or linear array.
Syntax :
datatype arrayname[size];
For Example :
Note :
By default array index should starts with zero (0)
Write a program for entering data into an
array & Reading data from an array
#include<stdio.h>
void main()
{
int arr[10],I,n;
printf("n ENter N Elements");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter arr[%d]=",i);
scanf("%d",&arr[i]);
}
for(i=0;i<n;i++)
{
printf("%dn",arr[i]);
}
}
Enter N Elements : 3
Enter arr[0] : 2
Enter arr[1] : 5
Enter arr[2] : 3
2
5
3
PROGRAM-ARRAY INITIALIZATION
Array Initialization
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5]={10,20,30,40,50};
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("%dn",a[i]);
}
getch();
}
10
20
30
40
50
Write a “C” program to sort the given number is in ascending order using one dimensional
array
#include<stdio.h>
void main()
{
int i,j,n, a[10],temp;
printf("n size of vector=");
scanf("%d",&n);
printf("vector elements:");
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
printf("nnElements in asending order is=n");
for(i=0;i<n;i++)
printf("%d",a[i]);
printf("nnElements in descending order is=n");
for(i=n-1;i>=0;i--)
printf("%d",a[i]);
getch();
}
Two Dimensional Arrays
A Arrays whose elements are specified by two subscript
such as row and column are called One dimensional array
or linear array.
Row  means horizontally
Column  means vertically
A two - dimensional array looks like a school time-table
consisting of rows and columns.
A two – dimensional array is declared as -
Two Dimensional Array Initialization
The result of the above assignment will be as follows :
Write a “C” program to perform the addition of two matrices
#include<stdio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf("Input A - Matrixn");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("Input B - Matrixn");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
printf("Sum of A and B Matrix=n");
for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("%d",c[i][j]);
printf("n");
}
}
Write a “C” program to perform the subtraction of two matrices
#include<stdio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf("Input A - Matrixn");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("Input B - Matrixn");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]-b[i][j];
printf("Sum of A and B Matrix=n");
for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("%d",c[i][j]);
printf("n");
}
}
Write a “C” program to sort the given names in Alphabetical order using One
dimensional array
#include<stdio.h>
#include<string.h>
void main()
{
int i,j,n;
char a[10][10],temp[10];
printf("n Enter the N Values");
scanf("%d",&n);
printf("Enter the Names one by one :n");
for(i=0;i<n;i++)
{
scanf("%s",&a[i]);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if((strcmp(a[i],a[j]))>0)
{
strcpy(temp,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],temp);
}
printf("The Names in Alphabetical Order is =n");
for(i=0;i<n;i++)
printf("n%s",a[i]);
}
Write a “C” program to perform matrix multiplication using two dimensional array
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,m,n,p,q,k;
printf("Input row and column of A matrix n");
scanf("%d %d",&n,&m);
printf(" Input row and column of B matrix n");
scanf("%d %d",&p,&q);
if(n==q){
printf(" Matrices can be Multiplied: n");
printf(" Input A-matrix n");
for(i=0;i<n;++i)
for(j=0;j<m;++j)
scanf("%d",&a[i][j]);
printf(" Input B-matrix n");
for(i=0;i<p;++i)
for(j=0;j<q;++j)
scanf("%d",&b[i][j]);
printf("The resultant matrix ist:n");
for(i=0;i<n;++i){
for(j=0;j<m;++j){
c[i][j]=0;
for(k=0;k<m;++k)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
printf("%d",c[i][j]);}
printf("n");}}
else
printf("Matrices cannot be multiplied n");
}
Write a “C” program to find the largest and smallest numbers given in the array
#include<stdio.h>
void main()
{
int i,n;
float a[20],large,small;
printf("nEnter the N values=");
scanf("%d",&n);
printf("Enter the values one by one :n");
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
}
large=a[0];
for(i=1;i<n;i++)
{
if(a[i]>large)
large=a[i];
}
small=a[0];
for(i=1;i<n;i++)
{
if(a[i]<small)
small=a[i];
}
printf("Largest element is = %fn",large);
printf("Smallest element = %fn",small);
}
Session Summary
 Arrayname should be a unique and valid “C” Variable name
 The number of elements in a multi dimensional array is the product of its subscripts
 Arrays can be initialized to the same type in which they are declared
 The character array receives the terminating ‘0’ in the string constant
 The individual values in the array are called as elements
 It is not necessary to specify the length of an array, explicitly in case if initializers are
provided for the array during declaration itself
EXERCISES
1. Write a program to search an element and to find how many times it is present in
the array?
2. Write a program to find the sum of diagonal elements in a matrix
3. Write a program to find the second largest number in an array?
4. Write a program to remove the duplicate elements of the array?
5. Write a program to merge two arrays and print the merged array in ascending
order?
6. Write a program to insert an element into an sorted array of integers?
7. Write a program to display only the negative elements of the array?

More Related Content

Similar to presentation_arrays_1443553113_140676.ppt (20)

Array
ArrayArray
Array
 
Session 7 En
Session 7 EnSession 7 En
Session 7 En
 
Session 7 En
Session 7 EnSession 7 En
Session 7 En
 
Array
ArrayArray
Array
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
array.ppt
array.pptarray.ppt
array.ppt
 
CP Handout#7
CP Handout#7CP Handout#7
CP Handout#7
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
Arrays
ArraysArrays
Arrays
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
CHAPTER 5
CHAPTER 5CHAPTER 5
CHAPTER 5
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
Array
ArrayArray
Array
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
 
Arrays
ArraysArrays
Arrays
 
2DArrays.ppt
2DArrays.ppt2DArrays.ppt
2DArrays.ppt
 
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
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
 
Arrays
ArraysArrays
Arrays
 

Recently uploaded

History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationEmaan Sharma
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalSwarnaSLcse
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxMustafa Ahmed
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualBalamuruganV28
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksIJECEIAES
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptamrabdallah9
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Toolssoginsider
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxMustafa Ahmed
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..MaherOthman7
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfJNTUA
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New HorizonMorshed Ahmed Rahath
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniR. Sosa
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.benjamincojr
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 

Recently uploaded (20)

History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 

presentation_arrays_1443553113_140676.ppt

  • 1.
  • 2. Session Objectives Explain Declaration,Initialization of Array Explain Types of Array One Dimensional,Two Dimensional and Multi Dimensional Array Explain Arrays
  • 3. Array is defined as a set of homogeneous data items. An Array is a group of elements that share a common name that are differentiated from one another by their positions within the array Datatype arrayname[subscript]; 1) Arrayname should be a valid “C” variable 2) Arrayname should be unique 3) The elements in the array should be of same type 4) Subscript (array size) cannot be negative 5) Subscript must always be an integer
  • 4.
  • 5. Single or One Dimensional Arrays Arrays whose elements are specified by one subscript are called One dimensional array or linear array. Syntax : datatype arrayname[size]; For Example : Note : By default array index should starts with zero (0)
  • 6. Write a program for entering data into an array & Reading data from an array #include<stdio.h> void main() { int arr[10],I,n; printf("n ENter N Elements"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter arr[%d]=",i); scanf("%d",&arr[i]); } for(i=0;i<n;i++) { printf("%dn",arr[i]); } } Enter N Elements : 3 Enter arr[0] : 2 Enter arr[1] : 5 Enter arr[2] : 3 2 5 3
  • 7. PROGRAM-ARRAY INITIALIZATION Array Initialization #include<stdio.h> #include<conio.h> void main() { int a[5]={10,20,30,40,50}; int i; clrscr(); for(i=0;i<5;i++) { printf("%dn",a[i]); } getch(); } 10 20 30 40 50
  • 8. Write a “C” program to sort the given number is in ascending order using one dimensional array #include<stdio.h> void main() { int i,j,n, a[10],temp; printf("n size of vector="); scanf("%d",&n); printf("vector elements:"); for (i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } printf("nnElements in asending order is=n"); for(i=0;i<n;i++) printf("%d",a[i]); printf("nnElements in descending order is=n"); for(i=n-1;i>=0;i--) printf("%d",a[i]); getch(); }
  • 9. Two Dimensional Arrays A Arrays whose elements are specified by two subscript such as row and column are called One dimensional array or linear array. Row  means horizontally Column  means vertically A two - dimensional array looks like a school time-table consisting of rows and columns. A two – dimensional array is declared as -
  • 10. Two Dimensional Array Initialization The result of the above assignment will be as follows :
  • 11. Write a “C” program to perform the addition of two matrices #include<stdio.h> void main() { int a[3][3],b[3][3],c[3][3],i,j; printf("Input A - Matrixn"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&a[i][j]); printf("Input B - Matrixn"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&b[i][j]); for(i=0;i<3;i++) for(j=0;j<3;j++) c[i][j]=a[i][j]+b[i][j]; printf("Sum of A and B Matrix=n"); for(i=0;i<3;++i) { for(j=0;j<3;++j) printf("%d",c[i][j]); printf("n"); } }
  • 12. Write a “C” program to perform the subtraction of two matrices #include<stdio.h> void main() { int a[3][3],b[3][3],c[3][3],i,j; printf("Input A - Matrixn"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&a[i][j]); printf("Input B - Matrixn"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&b[i][j]); for(i=0;i<3;i++) for(j=0;j<3;j++) c[i][j]=a[i][j]-b[i][j]; printf("Sum of A and B Matrix=n"); for(i=0;i<3;++i) { for(j=0;j<3;++j) printf("%d",c[i][j]); printf("n"); } }
  • 13. Write a “C” program to sort the given names in Alphabetical order using One dimensional array #include<stdio.h> #include<string.h> void main() { int i,j,n; char a[10][10],temp[10]; printf("n Enter the N Values"); scanf("%d",&n); printf("Enter the Names one by one :n"); for(i=0;i<n;i++) { scanf("%s",&a[i]); } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if((strcmp(a[i],a[j]))>0) { strcpy(temp,a[i]); strcpy(a[i],a[j]); strcpy(a[j],temp); } printf("The Names in Alphabetical Order is =n"); for(i=0;i<n;i++) printf("n%s",a[i]); }
  • 14. Write a “C” program to perform matrix multiplication using two dimensional array #include<stdio.h> void main() { int a[10][10],b[10][10],c[10][10],i,j,m,n,p,q,k; printf("Input row and column of A matrix n"); scanf("%d %d",&n,&m); printf(" Input row and column of B matrix n"); scanf("%d %d",&p,&q); if(n==q){ printf(" Matrices can be Multiplied: n"); printf(" Input A-matrix n"); for(i=0;i<n;++i) for(j=0;j<m;++j) scanf("%d",&a[i][j]); printf(" Input B-matrix n"); for(i=0;i<p;++i) for(j=0;j<q;++j) scanf("%d",&b[i][j]); printf("The resultant matrix ist:n"); for(i=0;i<n;++i){ for(j=0;j<m;++j){ c[i][j]=0; for(k=0;k<m;++k) c[i][j]=c[i][j]+a[i][k]*b[k][j]; printf("%d",c[i][j]);} printf("n");}} else printf("Matrices cannot be multiplied n"); }
  • 15. Write a “C” program to find the largest and smallest numbers given in the array #include<stdio.h> void main() { int i,n; float a[20],large,small; printf("nEnter the N values="); scanf("%d",&n); printf("Enter the values one by one :n"); for(i=0;i<n;i++) { scanf("%f",&a[i]); } large=a[0]; for(i=1;i<n;i++) { if(a[i]>large) large=a[i]; } small=a[0]; for(i=1;i<n;i++) { if(a[i]<small) small=a[i]; } printf("Largest element is = %fn",large); printf("Smallest element = %fn",small); }
  • 16. Session Summary  Arrayname should be a unique and valid “C” Variable name  The number of elements in a multi dimensional array is the product of its subscripts  Arrays can be initialized to the same type in which they are declared  The character array receives the terminating ‘0’ in the string constant  The individual values in the array are called as elements  It is not necessary to specify the length of an array, explicitly in case if initializers are provided for the array during declaration itself
  • 17. EXERCISES 1. Write a program to search an element and to find how many times it is present in the array? 2. Write a program to find the sum of diagonal elements in a matrix 3. Write a program to find the second largest number in an array? 4. Write a program to remove the duplicate elements of the array? 5. Write a program to merge two arrays and print the merged array in ascending order? 6. Write a program to insert an element into an sorted array of integers? 7. Write a program to display only the negative elements of the array?