PF Open Ended
PF Open Ended
Spring 2025
Task 1:
Create a simplified cinema ticket booking system using the C programming language.
The system should allow users to book seats for a cinema show by providing the row and column
of the seat they want to book.
The booking system will display the status of seats (booked or available) after each booking and
calculate the total cost based on the number of tickets booked.
Requirements:
● There should be a fixed number of rows and columns (e.g., 3 rows and 4 columns).
● All seats should initially be available (indicated by 0).
● Users will book one seat at a time by specifying the row and column numbers.
Booking Process:
● The system will prompt the user to enter a row and column number.
● If the seat is available, it will be marked as booked (1).
● If the seat is already booked, the user will be notified.
● After each booking, the seat arrangement will be displayed.
● The total cost will be calculated based on the number of seats booked. Assume each seat
costs Rs. 300.
Exiting the Program:
● After each booking, the user will be asked if they want to book another seat.
● If the user enters 1, they can book another seat.
Code:
#include <stdio.h>
int main() {
int seats[3][4] = {0};
int row, col;
int totalBooked = 0;
int choice = 1;
int price = 300;
while (choice == 1) {
printf("\nSeat Arrangement (0 = Available, 1 =
Booked):\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
printf("%d ", seats[i][j]);
}
printf("\n");
}
return 0;
}
Output:
a) Booking by client.
b) A number of seats that are taken and available.
c) The client wants to book more seats.
d) Total seats booked and total cost.
Explanation:
Explain the answers using the piece of code you write for that portion.
Can you explain how users book tickets in the program? What steps do they need to
follow?
For this purpose, User don’t have to cross the limits.User have to enter the input for booking
the seats. For this user must enter the number of row and column and these doesn’t exceed
the limits.
How does the program determine if a seat is available for booking?
If the seats are available initially represented by ‘0’ when user booked it, then it represented
as 1. User choose the row and column for the seat and pay (300Rs) for it.
Explain how the program decides when to stop booking tickets.
At the end when user want to stop to booking seats the program asked user “Do you want to
book another seat”. User have to enter 0 here and program will ended.
What does the program do if the user enters an invalid row or column number?
If the user do this, Program tell you the “Invalid seat”. And after it program will ended.
How does the program ensure a smooth exit when the booking process is complete?
When the user complete the booking of the seats then the user enter the ‘0’ and the program
will ended.