/* June 14, 1998 */ /* Program to determine class enrollment using functions, if and loops */ #include /* function definition */ int empty(int c, int e); main() { /* declarations */ int rnum; int cap; int enroll; /* request input */ printf("Enter room number> "); scanf("%d", &rnum); printf("Enter capacity of room> "); scanf("%d", &cap); printf("Enter current enrollment> "); scanf("%d", &enroll); /* display header */ printf("Room Capacity Enrollment Empty seats Filled/Not Filled\n"); /* display results */ if (cap == enroll) { printf("%d %8d %10d %10d %8c Filled\n", rnum, cap, enroll, empty(cap, enroll), ' '); } else { printf("%d %8d %10d %10d %8c Not Filled\n", rnum, cap, enroll, empty(cap, enroll), ' '); } printf("\n"); } /* function definition */ int empty(int c, int e) { /* local variable */ int seats; /* computation */ seats = c - e; return(seats); }