147
Q. Program to print the elements of an array.
Explanation
In this program, we need to create an array and print the elements present in the array.
Arrays are the special variable that stores multiple values under the same name. A contiguous memory will be allocated to store elements. Elements of the array can be accessed through their indexes.
Here, 1, 2, 3, 4 and 5 represent the elements of the array. These elements can be accessed through their corresponding indexes, i.e., 0, 1, 2, 3 and 4.
Algorithm
- Declare and initialize an array.
- Loop through the array by incrementing the value of i.
- Finally, print out each element of the array.
Solution
Python
Output:
Elements of given array: 1 2 3 4 5
C
Output:
Elements of given array: 1 2 3 4 5
JAVA
Output:
Elements of given array: 1 2 3 4 5
C#
Output:
Elements of given array: 1 2 3 4 5
PHP
Output:
Elements of given array: 1 2 3 4 5
Next Topic#