Professional Documents
Culture Documents
Lecture 0
Revision
Revision to some concepts of OOP
Arrays
Pointers
Arrays
Declaration of an array.
Initialization of an array.
Accessing single element of an array.
Accessing elements of an array using Loops.
Input and Output values of an array.
Write a program that inputs five integers from the
user and stores them in an array. It then display all
the values in the array using loops.
Solution
Void main() {
Int arr[5], i;
For(i=0, i<5, i++){
;”:Cout<< “Enter an integer
};Cin >> arr[i]
Cout<< “values of an array are:”
For(i=0, i<5, i++){
;Cout<< arr[i]<<endl
getch();
}
Types of Arrays
1-Dimensional Array
2-Dimensional Array
Multidimensional Array
D Array-2
}};Cout<<endl
getch();
}
Multidimensional Array
Array of arrays.
Can have three, four or more dimensions.
Rapidly increases the amount of memory required with each dimension.
References