Arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Arrays

can we give the number of elements (which the array consists) in the bracket int[.....] myArray (name of the array)???

16th Dec 2017, 8:05 AM
Muthahhar Mahroof
Muthahhar Mahroof - avatar
1 Answer
+ 8
yes we can give the number of elements (which the array consists) in the bracket The size (in brackets) must be an integer literal or a constant variable. The compiler uses the size to determine how much space to allocate (i.e. how many bytes). Examples: int list[30]; // an array of 30 integers char name[20]; // an array of 20 characters double nums[50]; // an array of 50 decimals int table[5][10]; // a two dimensional array of integers
16th Dec 2017, 8:22 AM
GAWEN STEASY
GAWEN STEASY - avatar