Explain the output of this code: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
24th Feb 2020, 12:01 PM
Prathvi
Prathvi - avatar
4 Answers
+ 2
Chetali Shah , yes but how?
24th Feb 2020, 12:58 PM
Prathvi
Prathvi - avatar
0
I guess the output is 10. I am not sure either.
24th Feb 2020, 12:44 PM
Chetali Shah
Chetali Shah - avatar
0
See the C structure contains variables for A structure and B structure and both of them have 2 more variable. That means the 4 values passed in c1,c2 will be distributed between them as first 2 values will go in a and last 2 in b. Now, c1.b.a leads to calling of b variable of B structure and in that we are refering to a variable. The first 2 values of c1 are passed to A structure and last 2 to B structure. And a element being the last gets the last value passed in c1 which is 4. Similarly, in the case of c2.a.b the A structure gets the first two values and in which b gets 6. So adding 4 and 6 is equal to 10.
24th Feb 2020, 1:27 PM
Chetali Shah
Chetali Shah - avatar
0
Coder Kitten thanks bro
24th Feb 2020, 3:14 PM
Prathvi
Prathvi - avatar