004-007-004
Array Length: The length Property
Easy
Problem Description
Array Length: The length Property
In this problem, you will create a program that reads an array size and string elements from standard input, retrieves the element count using the .length property, and displays the array contents and count to standard output.
Learning Objective: Understand how to get the number of elements using the length property
Overview
The number of elements in an array can be obtained using the .length property. It returns the size determined at array declaration.
Input Format
- Line 1: Array size N
- Lines 2 to N+1: N strings (one per line)
Output Format
Fruits: elem1, elem2, ..., elemN
Count: N
Input Example
4
Apple
Banana
Orange
Grape
Output Example
Fruits: Apple, Banana, Orange, Grape
Count: 4
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up