Arrays in c++
Typing Speed:19

muhammed ajmal
ajmalmp777@gmail.com
ajmalmp
ajmalmp
in.linkedin.com/in/profilena
me
8547712876
Arrays in c ++
• An array is a collection of same type of
elements which are sheltered under a
common name.
One-dimensional arrays
• One dimensional array have only one
subscript under a common name.
• syntax
• Data_type array_name[array_size];
• Example
• int age[5]={2,4,34,3,4};
Example program
•
•
•
•
•
•

#include<iostream>
using namespace std;
int main()
{
int a[4];
int i ;

•
•
•
•
•
•
•
•

for (i = 0; i < 4; i++)
{

a[i][j] = 0;
cout << a[i][j]<<" " ;
}
}
Two-dimensional arrays
• Two-dimensional array are those type of
array, which has finite number of rows and
finite number of columns.
• Data_type Array_name [row size][column
size];
Example program
•
•
•
•
•
•

#include<iostream>
using namespace std;
int main()
{
int a[4][4];
int i , j;

•
•
•
•
•
•
•
•
•

for (i = 0; i < 4; i++)
{
for ( j = 0; j < 4; j++)
{
a[i][j] = 0;
cout << a[i][j]<<" " ;
}
}
}
Multi-dimensional arrays

• An array have multiple subscript under a
common name.
• Syntax
• type name[size1][size2]...[sizeN];

• Example
• float a[2][6][7][4]….[n];
•
•

•
•
•
•
•
•
•
•
•
•

#include<iostream>
using namespace std;

int main()
{
int a[4][4][4];
int i , j,k;
for (i = 0; i < 4; i++)
{
for ( j = 0; j < 4; j++)
{
for ( k = 0; k < 4; k++)
{

•
•
•
•
•

a[i][j] [k]= 0;
cout << a[i][j][k]<<" " ;
}

}
}
• Subscripted Variable Rules
• Subscripted variables can be double, integer,
or character.
• The maximum number of subscripts is dictated by the
compiler vendor. Twelve is common.
• Arithmetic expressions may be used for subscripts.
• Subscripts must be integer valued.
• A statement must be included in your program which
sets aside storage space (dimensions) for your arrays.
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.

Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Arrays in c++

  • 2.
    Arrays in c++ TypingSpeed:19 muhammed ajmal ajmalmp777@gmail.com ajmalmp ajmalmp in.linkedin.com/in/profilena me 8547712876
  • 3.
    Arrays in c++ • An array is a collection of same type of elements which are sheltered under a common name.
  • 4.
    One-dimensional arrays • Onedimensional array have only one subscript under a common name. • syntax • Data_type array_name[array_size]; • Example • int age[5]={2,4,34,3,4};
  • 5.
    Example program • • • • • • #include<iostream> using namespacestd; int main() { int a[4]; int i ; • • • • • • • • for (i = 0; i < 4; i++) { a[i][j] = 0; cout << a[i][j]<<" " ; } }
  • 6.
    Two-dimensional arrays • Two-dimensionalarray are those type of array, which has finite number of rows and finite number of columns. • Data_type Array_name [row size][column size];
  • 7.
    Example program • • • • • • #include<iostream> using namespacestd; int main() { int a[4][4]; int i , j; • • • • • • • • • for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { a[i][j] = 0; cout << a[i][j]<<" " ; } } }
  • 8.
    Multi-dimensional arrays • Anarray have multiple subscript under a common name. • Syntax • type name[size1][size2]...[sizeN]; • Example • float a[2][6][7][4]….[n];
  • 9.
    • • • • • • • • • • • • #include<iostream> using namespace std; intmain() { int a[4][4][4]; int i , j,k; for (i = 0; i < 4; i++) { for ( j = 0; j < 4; j++) { for ( k = 0; k < 4; k++) { • • • • • a[i][j] [k]= 0; cout << a[i][j][k]<<" " ; } } }
  • 10.
    • Subscripted VariableRules • Subscripted variables can be double, integer, or character. • The maximum number of subscripts is dictated by the compiler vendor. Twelve is common. • Arithmetic expressions may be used for subscripts. • Subscripts must be integer valued. • A statement must be included in your program which sets aside storage space (dimensions) for your arrays.
  • 11.
    If this presentationhelped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 12.
    Contact Us Emarald Mall(Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550