Skip to content

Instantly share code, notes, and snippets.

@saikksub
Created October 19, 2023 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saikksub/51c129b4da800e2f2c80921155b56f62 to your computer and use it in GitHub Desktop.
Save saikksub/51c129b4da800e2f2c80921155b56f62 to your computer and use it in GitHub Desktop.
Seat Selection Task

Seat Selection Task

Objective

Implement a C program that manages seat bookings for an event.

Specifications

  • Seats: [-1, -1, 0, 1, 2]. Here, -1 indicates the seat is not available, and any non-negative integer indicates the seat number.

  • Emails: ["test1@gmail.com", "test2@gmail.com", "test3@gmail.com"].

  • The program should display the following options:

Options

  1. View all seats booked
  2. View all seats available
  3. Clear all seats booked
  4. New seat booking

Based on the option selected:

  • Option 1: Display all the seats with seat number and email.

Example:

2: test1@gmail.com
3: test2@gmail.com
4: test3@gmail.com
  • Option 2: Display all available seats for new booking.

Example:

0: Free
1: Free
  • Option 3: Clear all the bookings and display the list of available seats.

Example:

0: Free
1: Free
2: Free
3: Free
4: Free
  • Option 4: Allow the user to book a new seat.

Example:

0: Free
1: Free
2: Free
3: Free
4: Free

Select the seat number:
Enter email address:

The email address provided by the user should be validated. If the email is not in a valid format, prompt the user to enter it again.

Assumptions

  1. A seat can only be booked by one email at a time.
  2. The email validation should check for the presence of the '@' symbol and a domain. For the purpose of this challenge, you can consider an email to be valid if it contains the '@' symbol and a dot (.) after the '@' symbol.

Sample Inputs

  • Seats: [-1, -1, 0, 1, 2]
  • Emails: ["test1@gmail.com", "test2@gmail.com", "test3@gmail.com"]

Sample Outputs

As specified above based on user's choice.


Note: Implement the program ensuring proper user input handling. If a user tries to book an already booked seat, the program should handle such cases gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment