Chapter 4 - Arrays in C++
Chapter 4 - Arrays in C++
0 1 2 3 4
0
1
2
1.4 Arrays in C++
- Matrix represents a bi-dimensional array of 3 per 5 values
of type int. The way to declare this array would be:
- int matrix[3][5];
1.4 Arrays in C++
1.4.4 Accessing Array Elements
- An element is accessed by indexing the array name.
- This is done by placing the index of the element within
square brackets after the name of the array.
- For example: double salary = balance[9];
- The above statement will take 10th element from the array
and assign the value to salary variable.
- Following is an example, which will use all the above-
mentioned three concepts: declaration, assignments and
accessing arrays.
1.4 Arrays in C++
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int n[10];
return 0;
}
1.4 Arrays in C++
Sample output:
1.4 Arrays in C++
Special Thanks to the publisher and author with:
TOPICS AND THE CONCEPTS:
What is Array?
Accessing Array Elements
Array Declaration
Initializing Arrays
Properties of Arrays
REFERENCES:
C++ Programming: From Problem Analysis to Program Design (D.S. Malik)
Fundamental of Programming in C++ (Walter J. Savitch)
PRESENTED BY:
Mohammed Nebil
SPECIAL THANKS:
Digital Library of Educations
Federal Democratic Republic of Ethiopia, Ministry of Educations
Ethiopian Education Short Note