data-structures · beginner · ~15 min
Pass a struct by value and use its fields.
Define struct Rect { int w, h; }; and implement long rect_area(struct Rect r) returning w*h.
struct Rect { int w, h; };
long rect_area(struct Rect r) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.