Develop a C++ program for a simple Movie Ticket Booking System that allows customers
to:
1. View available seats in a single row of 5 seats.
2. Book a seat by selecting a seat number (1-5).
3. Receive a random prize after successfully booking a seat.
4. Exit the system when done.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int SEATS = 5; // Number of seats
char seats[SEATS]; // Seat availability array
// Function to initialize seats as 'A' (Available)
void initializeSeats() {
for (int i = 0; i < SEATS; i++) {
seats[i] = 'A';
// Function to display seats
void displaySeats() {
cout << "\nSeating Arrangement (A = Available, B = Booked)\n";
for (int i = 0; i < SEATS; i++) {
cout << "[" << seats[i] << "] ";
cout << "\n";
}
// Function to assign a random prize
string assignPrize() {
string prizes[] = {"Free Popcorn!", "Free Drink!", "Discount on Next Ticket!", "No
Prize."};
return prizes[rand() % 4]; // Randomly select a prize
// Function to book a seat
void bookSeat() {
int seatNumber;
cout << "Enter seat number (1-" << SEATS << "): ";
cin >> seatNumber;
if (seatNumber < 1 || seatNumber > SEATS) {
cout << "Invalid seat number! Try again.\n";
return;
if (seats[seatNumber - 1] == 'B') {
cout << "Seat already booked! Choose a different seat.\n";
} else {
seats[seatNumber - 1] = 'B'; // Mark seat as booked
cout << "Seat successfully booked!\n";
cout << "Congratulations! Your prize: " << assignPrize() << "\n";
}
int main() {
srand(time(0)); // Seed random number generator
initializeSeats();
int choice;
do {
cout << "\nMovie Ticket Booking System\n";
cout << "1. View Seats\n";
cout << "2. Book a Seat\n";
cout << "3. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: displaySeats(); break;
case 2: bookSeat(); break;
case 3: cout << "Exiting system. Enjoy your movie!\n"; break;
default: cout << "Invalid choice! Please try again.\n";
} while (choice != 3);
return 0;
Movie Ticket Booking System
1. View Seats
2. Book a Seat
3. Exit
Enter your choice: 1
Seating Arrangement (A = Available, B = Booked)
[A] [A] [A] [A] [A]
Enter your choice: 2
Enter seat number (1-5): 3
Seat successfully booked!
Congratulations! Your prize: Free Drink!
Enter your choice: 1
Seating Arrangement (A = Available, B = Booked)
[A] [A] [B] [A] [A]
Enter your choice: 3
Exiting system. Enjoy your movie!