0
How to declare values into a variable from an array?
For example: int a [3] = {1, 2, 3}; int b; int c; b = c = and I want values 2 and 3 to be declared in b and 1 in c. How is it possible? Thanks for your time.
8 Answers
0
If you edited (cause of syntax error), I think it's working.
+ 7
int[] a = {1,2,3};
int[] b = {a[1], a[2]};
int c = a[0];
+ 5
If you want both values to be in b, then b must be an array. A single int cannot hold 2 different values, Unless you want the numbers to be combined.
+ 1
b = a[1] + a[2];
c = a[0];
+ 1
int b[] = {2, 3};
It is
0
I think that this will add the two values and not declaring two values.
0
Can a single variable have more than one value? at a time
0
I thought it would be possible in arrays.