SlideShare a Scribd company logo
Arrays
Declaration & Initialization
For understanding the arrays properly, let us consider
the following program:
main( )
{
int x ;
x = 5 ;
x = 10 ;
cout<< x<<endl ;
}
• There are situations in which we would want to store
more than one value at a time in a single variable.
• For example, suppose we wish to arrange the marks
obtained by 100 students
• In such a case we have two options to store these marks
• Construct 100 variables to store marks obtained by 100
different students, i.e. each variable containing one
student’s marks.
• Construct one variable capable of storing or holding all
the hundred values.
• Obviously, the second alternative is better.
• A simple reason for this is, it would be much easier to
handle one variable than handling 100 different variables
Arrays
• When we want to store more than one value at a time
in a single variable, we require an array
• Array is the collection of similar data types stored in
contiguous memory location
• Each data item of an array is called an element.
• Each element is located in separated memory location.
• Each of elements of an array have different index no.
known as subscript
• Thus, an array can be considered as a subscripted
variable
ADVANTAGE:
• Array variable can store more than one value at a time
where other variable can store one value at a time.
An array of integers
• All elements in the array are of type integer
• The length of the array is 10
• The array is indexed from 0 to 9
3 16 -1 0 8 7 1 55 -3 1
An array of integers
• All elements in the array are of type integer
• The length of the array is 10
• The array is indexed from 0 to 9
• The element at index 0 is 3
3 16 -1 0 8 7 1 55 -3 1
index
0
An array of integers
• All elements in the array are of type integer
• The length of the array is 10
• The array is indexed from 0 to 9
• The element at index 4 is 8
3 16 -1 0 8 7 1 55 -3 1
index
4
An array of integers
• All elements in the array are of type integer
• The length of the array is 10
• The array is indexed from 0 to 9
• The element at index 7 is 55
3 16 -1 0 8 7 1 55 -3 1
index
7
An array of integers
• All elements in the array are of type integer
• The length of the array is 10
• The array is indexed from 0 to 9
• The element at index 9 is 1
3 16 -1 0 8 7 1 55 -3 1
index
9
An array of Floats and Characters
• Array of Floats
• Array of Characters
3.5 1.4 7.8 8.8 9.4 9.9 3.5 6.8 5.0 5.5
W E L L C O M E B K
NOT AN ARRAY
3 1.5 -1 0 6.7 R D 5.5 -3 1
Array Declaration
• The statement int A;
declares a single integer variable named A
Syntax: type arrayName [ arraySize ];
• The statement int A[5];
float B[10];
declares
• Array variable A that can hold 5 integer values
• Array variable B that can hold 10 float values
• The size and type of arrays cannot be changed after its
declaration.
Initializing Array
• Syntax:
type arrayName [ arraySize ]={element1,element2….elementN };
• It's possible to initialize an array during declaration.
int A[5] = {35, 20, 40, 57, 19};
• Another method to initialize array during declaration:
int A[] = {35, 20, 40, 57, 19};
OR
A[0]= 35 ;
A[1]= 20 ;
A[2]= 40 ;
A[3]= 57 ;
A[4]= 19 ;
C++ program
• # include<iostream.h>
• #include<conio.h>
• main()
• {
• int x[5] , i;
• cout<<“Enter values into array”<<endl;
• for(i=0;i<5l;i++)
{
• cin>>x[i];
}
• cout<<“The values you entered into array are ”<<endl;
for(i=0;i<5l;i++)
• {
• cout<<x[i]<<endl;
• }
• }
TWO – DIMENTIONAL ARRAY:
If you want to store data into table or matrix form at that time you
can use the two dimensional array.
Declaration of two dimentional array:
Syntax : data_type array-name[dim1][dim2];
Where dim1 indicates total rows and dim2 indicates total
columns.
Ex: ITEM 1 ITEM2ITEM 3
SALES MAN 1 310 275 365
SALES MAN 2 210 190 325
SALES MAN 3 405 235 240
SALES MAN 4 260 300 380
Initializing two dimentional array:
Ex: int table[2][3] = {0,0,0,1,1,1};
int table[2][3] = {
{0,0,0},
{1,1,1}
} ;
Initializing two dimentional array:
When the array is completely initialized with all values,
we need not specify the size of the first dimension. That
is, the statement is permitted.
int table[][3] = {
{0,0,0} ,
{1,1,1)
};
C++ program
• # include<iostream.h>
• #include<conio.h>
• main()
• {
• int x[2][3] , i,j;
• cout<<“Enter values into array”<<endl;
• for(i=0;i<2l;i++)
• {
• for(j=0;j<3;j++)
{
• cin>>x[i][j];
}
}
• cout<<“The values you entered into array are ”<<endl;
• for(i=0;i<2l;i++)
• {
• for(j=0;j<3;j++)
{
• cout<<x[i][j];
}
}
}

More Related Content

Similar to arrayy.ppt

Week06
Week06Week06
Week06hccit
 
Array-part1
Array-part1Array-part1
Array-part1
AbishaiAsir
 
SPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in CSPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
berekethailu2
 
Learn Java Part 8
Learn Java Part 8Learn Java Part 8
Learn Java Part 8
Gurpreet singh
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
Ashim Lamichhane
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injavairdginfo
 
Array
ArrayArray
Arrays
ArraysArrays
Arrays
Neeru Mittal
 
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
ajajkhan16
 
Arrays
ArraysArrays
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
Maliha Mehr
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
dfsdg3
 
Lecture 6 - Arrays
Lecture 6 - ArraysLecture 6 - Arrays
Lecture 6 - Arrays
Syed Afaq Shah MACS CP
 
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
teddiyfentaw
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
Munazza-Mah-Jabeen
 
Cso gaddis java_chapter8
Cso gaddis java_chapter8Cso gaddis java_chapter8
Cso gaddis java_chapter8RhettB
 

Similar to arrayy.ppt (20)

Week06
Week06Week06
Week06
 
Array-part1
Array-part1Array-part1
Array-part1
 
SPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in CSPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in C
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
Learn Java Part 8
Learn Java Part 8Learn Java Part 8
Learn Java Part 8
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
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
 
Arrays
ArraysArrays
Arrays
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 6 - Arrays
Lecture 6 - ArraysLecture 6 - Arrays
Lecture 6 - Arrays
 
2 arrays
2   arrays2   arrays
2 arrays
 
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
Cso gaddis java_chapter8
Cso gaddis java_chapter8Cso gaddis java_chapter8
Cso gaddis java_chapter8
 

Recently uploaded

一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Florence Consulting
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
CIOWomenMagazine
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
nhiyenphan2005
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
harveenkaur52
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 

Recently uploaded (20)

一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 

arrayy.ppt

  • 2. For understanding the arrays properly, let us consider the following program: main( ) { int x ; x = 5 ; x = 10 ; cout<< x<<endl ; }
  • 3. • There are situations in which we would want to store more than one value at a time in a single variable. • For example, suppose we wish to arrange the marks obtained by 100 students • In such a case we have two options to store these marks
  • 4. • Construct 100 variables to store marks obtained by 100 different students, i.e. each variable containing one student’s marks. • Construct one variable capable of storing or holding all the hundred values.
  • 5. • Obviously, the second alternative is better. • A simple reason for this is, it would be much easier to handle one variable than handling 100 different variables
  • 6. Arrays • When we want to store more than one value at a time in a single variable, we require an array • Array is the collection of similar data types stored in contiguous memory location • Each data item of an array is called an element. • Each element is located in separated memory location.
  • 7. • Each of elements of an array have different index no. known as subscript • Thus, an array can be considered as a subscripted variable ADVANTAGE: • Array variable can store more than one value at a time where other variable can store one value at a time.
  • 8. An array of integers • All elements in the array are of type integer • The length of the array is 10 • The array is indexed from 0 to 9 3 16 -1 0 8 7 1 55 -3 1
  • 9. An array of integers • All elements in the array are of type integer • The length of the array is 10 • The array is indexed from 0 to 9 • The element at index 0 is 3 3 16 -1 0 8 7 1 55 -3 1 index 0
  • 10. An array of integers • All elements in the array are of type integer • The length of the array is 10 • The array is indexed from 0 to 9 • The element at index 4 is 8 3 16 -1 0 8 7 1 55 -3 1 index 4
  • 11. An array of integers • All elements in the array are of type integer • The length of the array is 10 • The array is indexed from 0 to 9 • The element at index 7 is 55 3 16 -1 0 8 7 1 55 -3 1 index 7
  • 12. An array of integers • All elements in the array are of type integer • The length of the array is 10 • The array is indexed from 0 to 9 • The element at index 9 is 1 3 16 -1 0 8 7 1 55 -3 1 index 9
  • 13. An array of Floats and Characters • Array of Floats • Array of Characters 3.5 1.4 7.8 8.8 9.4 9.9 3.5 6.8 5.0 5.5 W E L L C O M E B K
  • 14. NOT AN ARRAY 3 1.5 -1 0 6.7 R D 5.5 -3 1
  • 15. Array Declaration • The statement int A; declares a single integer variable named A Syntax: type arrayName [ arraySize ]; • The statement int A[5]; float B[10]; declares • Array variable A that can hold 5 integer values • Array variable B that can hold 10 float values • The size and type of arrays cannot be changed after its declaration.
  • 16.
  • 17. Initializing Array • Syntax: type arrayName [ arraySize ]={element1,element2….elementN }; • It's possible to initialize an array during declaration. int A[5] = {35, 20, 40, 57, 19}; • Another method to initialize array during declaration: int A[] = {35, 20, 40, 57, 19}; OR A[0]= 35 ; A[1]= 20 ; A[2]= 40 ; A[3]= 57 ; A[4]= 19 ;
  • 18.
  • 19. C++ program • # include<iostream.h> • #include<conio.h> • main() • { • int x[5] , i; • cout<<“Enter values into array”<<endl; • for(i=0;i<5l;i++) { • cin>>x[i]; } • cout<<“The values you entered into array are ”<<endl; for(i=0;i<5l;i++) • { • cout<<x[i]<<endl; • } • }
  • 20. TWO – DIMENTIONAL ARRAY: If you want to store data into table or matrix form at that time you can use the two dimensional array. Declaration of two dimentional array: Syntax : data_type array-name[dim1][dim2]; Where dim1 indicates total rows and dim2 indicates total columns. Ex: ITEM 1 ITEM2ITEM 3 SALES MAN 1 310 275 365 SALES MAN 2 210 190 325 SALES MAN 3 405 235 240 SALES MAN 4 260 300 380
  • 21.
  • 22. Initializing two dimentional array: Ex: int table[2][3] = {0,0,0,1,1,1}; int table[2][3] = { {0,0,0}, {1,1,1} } ;
  • 23. Initializing two dimentional array: When the array is completely initialized with all values, we need not specify the size of the first dimension. That is, the statement is permitted. int table[][3] = { {0,0,0} , {1,1,1) };
  • 24. C++ program • # include<iostream.h> • #include<conio.h> • main() • { • int x[2][3] , i,j; • cout<<“Enter values into array”<<endl; • for(i=0;i<2l;i++) • { • for(j=0;j<3;j++) { • cin>>x[i][j]; } }
  • 25. • cout<<“The values you entered into array are ”<<endl; • for(i=0;i<2l;i++) • { • for(j=0;j<3;j++) { • cout<<x[i][j]; } } }