Q. Program to print the number of elements present in an array.ExplanationIn this program, we need to count and print the number of elements present in the array. A number of elements present in the array can be found by calculating the length of the array. Length of above array is 5. Hence, the number of elements present in the array is 5. Algorithm
SolutionPythonArrays in Python is declared as len() method returns the length of the array in Python. Output: Number of elements present in given array: 5 CArrays in C are declared as "sizeof" operator gives the size of the array in bytes so, to get the length of the array we divide the size of the array with the size of the first element. Output: Number of elements present in given array: 5 JAVAArrays in Java are created using a new keyword as length property is used to calculate the length of the array. Output: Number of elements present in given array: 5 C#Arrays in C# are created using new keyword as Array. Length property is used to calculate the length of the array. Output: Number of elements present in given array: 5 PHPArrays in PHP are declared using Array (): count () is in-built function in PHP to get the length of array. Output: Number of elements present in given array: 5 Next Topic# |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India