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};
5 Answers
+ 1
but he needs the no. of terms in the array....how will knowing bytes help him??
+ 1
okayy....I get it...thanx for the knowledge đ
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.
- 1
cout>>a.length;
- 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)