/* Program to demonstrate the use of structures. Here structures are passed as arguments to functions. */ #include struct person { char *name; int age; int weight; }; void changePerson1(struct person p); void showPerson1(struct person p); int main() { struct person bob, sue; sue.name = "Sue"; sue.age = 21; sue.weight = 120; bob.name = "Bob"; bob.age = 62; bob.weight = 180; showPerson1(sue); printf("*** Before changePerson1() ***\n"); showPerson1(bob); changePerson1(bob); printf("*** After changePerson1() ***\n"); showPerson1(bob); return 0; } /* Function to display the elements in a person. */ void showPerson1(struct person p) { printf("name: %s\n", p.name); printf("age: %d\n", p.age); printf("weight: %d\n", p.weight); return; } /* Function to modify the elements in a person. */ void changePerson1(struct person p) { p.age = p.age - 2; p.weight = p.weight - 5; printf("*** In changePerson1() ***\n"); showPerson1(p); return; }