0

Find the number of elements in an array without using inbuilt functions

if user enters 1,2,3,4,5 the output should be 5 (without using string.length or any inbuilt functions)

25th Sep 2017, 5:16 PM
ASHOK KUMAR
ASHOK KUMAR - avatar
2 Réponses
+ 9
// There you go! I didn't take any input here but the method works ;D int[] arr = {2, 9, 12, 4, 6}; int count = 0; for(int i : arr) { count++; } System.out.print(count);
25th Sep 2017, 6:43 PM
Dev
Dev - avatar
30th Oct 2020, 2:44 AM
Balaji
Balaji - avatar