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.

9th May 2017, 5:11 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
8 Answers
0
If you edited (cause of syntax error), I think it's working.
9th May 2017, 5:45 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
+ 7
int[] a = {1,2,3}; int[] b = {a[1], a[2]}; int c = a[0];
9th May 2017, 5:26 PM
Rrestoring faith
Rrestoring faith - avatar
+ 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.
9th May 2017, 5:22 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
b = a[1] + a[2]; c = a[0];
9th May 2017, 5:11 PM
Jadude
+ 1
int b[] = {2, 3}; It is
9th May 2017, 5:26 PM
Jadude
0
I think that this will add the two values and not declaring two values.
9th May 2017, 5:15 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar
0
Can a single variable have more than one value? at a time
9th May 2017, 5:19 PM
Jadude
0
I thought it would be possible in arrays.
9th May 2017, 5:22 PM
Γιάννης Δημητριάδης
Γιάννης Δημητριάδης - avatar