+ 1

Can we access the elements of array outside the for loop? Please give reason also.

20th Oct 2016, 10:21 AM
Jaya
3 Answers
+ 2
If you have initialized the variable before the loop then you can use it outside loop & & if you have initialized it inside loop you cannot use it outside the loop
20th Oct 2016, 11:54 AM
Jishnu
Jishnu - avatar
+ 1
as long as the array wasn't declared and defined in the for loop, you can access the elements outside the for loop by using the index of the element. for example, arr[index]
20th Oct 2016, 10:50 AM
yungcheda
yungcheda - avatar
- 1
yes using :: this operator
20th Oct 2016, 2:58 PM
pavan
pavan - avatar