C Example: Seat Booking: 2D map, reserve, cancel and occupancy count

🗓 Last updated: 2026-11-30👤 Written by: Gray✓ Reviewed by: Alex🏷 Category: Mini Apps

Represents seats as a 7×6 character matrix, '.' free and 'X' booked; reserve validates row/column bounds and occupancy, cancel only releases booked seats, and the program prints the map and counts free seats. Shows a 2D array as a state table with full bounds checking.

🌱 Beginner Reference entries: kw-charkw-staticfn-printf
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
C · GCC 10.2 · -std=c11
Ada        R2C3 -> booked
Grace      R2C3 -> taken
Linus      R5C6 -> booked
Ken        R10C3 -> invalid
Margaret   R8C7 -> invalid

seat map:
     1 2 3 4 5 6
R1   . . . . . .
R2   . . X . . .
R3   . . . . . .
R4   . . . . . .
R5   . . . . . X
R6   . . . . . .
R7   . . . . . .

cancel R1C2 -> ok
cancel R9C2 -> invalid

after cancel:
     1 2 3 4 5 6
R1   . . . . . .
R2   . . . . . .
R3   . . . . . .
R4   . . . . . .
R5   . . . . . X
R6   . . . . . .
R7   . . . . . .
free seats: 41/42
🧩 Keep Learning

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏