+ 1

How should i do to set something in arrays?

21st Jul 2018, 8:24 AM
Ahmad Zahidi Bin Azmi
Ahmad Zahidi Bin Azmi - avatar
3 Respostas
+ 4
int array[5]; array[0] = 42; array[1] = 0; // etc or using a loop for (int i = 0; i < 5; i++) array[i] = some_value;
21st Jul 2018, 8:32 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
tq
21st Jul 2018, 8:33 AM
Ahmad Zahidi Bin Azmi
Ahmad Zahidi Bin Azmi - avatar
+ 1
You can also assign values in the declaration, but the syntax depends on the programming language: Java: int[] nums = {1,2,3}; OR int[] nums = new int[]{1,2,3}; Javascript: var nums = [1, 2, 3]; C#: int[] nums = { 1, 3, 5, 7, 9 }; . . .
21st Jul 2018, 10:45 AM
Guillem Padilla
Guillem Padilla - avatar