How to find the size of an array???(In c++) Without using any predefined function if the array is in below form: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to find the size of an array???(In c++) Without using any predefined function if the array is in below form:

a[]={1,2,3,4,5,6,0,3,5,2};

6th Sep 2017, 4:15 AM
ASHISH RAKESH
ASHISH RAKESH - avatar
5 Answers
+ 1
but he needs the no. of terms in the array....how will knowing bytes help him??
6th Sep 2017, 5:42 AM
Neil Bhowmik
Neil Bhowmik - avatar
+ 1
okayy....I get it...thanx for the knowledge 😁
6th Sep 2017, 5:46 AM
Neil Bhowmik
Neil Bhowmik - avatar
0
sizeof (a)/sizeof (a [0]) sizeof returns how many btyes something uses so it is dividing the total size of the array by the size of a single value.
6th Sep 2017, 5:41 AM
Enzo
Enzo - avatar
- 1
cout>>a.length;
6th Sep 2017, 5:31 AM
Neil Bhowmik
Neil Bhowmik - avatar
- 1
well lets say its an int array with 5 items and each item is 4 bytes. that would be a total of 20 bytes, then divide that 20 by the amount of bytes in a single int (4) and it makes 5 (number of items)
6th Sep 2017, 5:44 AM
Enzo
Enzo - avatar