return c;
}
(d)
Complex add_complex(Complex c1, Complex c2)
{
Complex c3;
c3.real = c1.real + c2.real;
c3.imaginary = c1.imaginary + c2.imaginary;
return c3;
}
11. [was #10; modified] The a member will occupy 8 bytes, the union e will take 8 bytes (the largest member, c, is 8 bytes long), and the array f will require 4 bytes, so the total space allocated for s will be 20 bytes.
14. [was #12; modified]
(a)
double area(struct shape s)
{
if (s.shape_kind == RECTANGLE)
return s.u.rectangle.height * s.u.rectangle.width;
else
return 3.14159 * s.u.circle.radius * s.u.circle.radius; }
(b)
struct shape move(struct shape s, int x, int y)
{
struct shape new_shape = s;
new_shape.center.x += x;
new_shape.center.y += y;
return new_shape;
}
(c)