+ 6
Please someone explain cout<<c1.a.b+c2.b.a;
10 Respuestas
+ 6
Divide it like this (c1.a).b it means
c1.a is referring to structure of type A then dot b means I am accessing the member float b of structure A
same way c2.b.a means I am referring to structure of type B and then by dot a I am accessing member a of structure B..answer should be this
c1.a.b = 2.0 and c2.b.a= 8.0 =10 (sum)
I think 10 should be answer
+ 5
Code ?? any ?? I mean if you could post the code then it would be easier to explain
+ 5
struct A {
int a;
float b;}
struct B{int b;
float a;
}
struct C {
A a;B b;
}
int main(){ C c1={1,2,3,4};
C c2={5,6,7,8};
cout<<c1.a.b+c2.b.a;
}
+ 4
Is it correct ?? @amit
+ 4
1 thing add semicolon after each structure declaration 😃
+ 3
i DONT UNDERSTAND this problem either; why the objects chosen ones are 2 and 8???
+ 2
thank you @joy
+ 2
yes answer is 10 @joy....
and I have one more question is it like??
c1 ={1,2,3,4}= {aa,ab,bb,ba}
+ 1
how c1.a.b got 2 and c2.b.a got 8??
+ 1
Thank you!😃