Mini Project DSA
Mini Project DSA
On
Bus Reservation System
For
Data Structure and Algorithms (CAN605)
Session 2024-25
CERTIFICATE
Certified that project report entitled “Bus Reservation System” submitted by “Sawan ”
during the period 2024-2025 in partial fulfilment of the requirements for the award of degree
of MCA of DIT University, Dehradun, is a record of work carried out under my guidance and
supervision. The project report embodies result of referred work and studies carried out by
student themselves and the content of the report do not form the basis for the award of any
other degree to the candidate or to anybody of the team.
Asst. Professor
ACKNOWLEDGEMENT
Apart from the efforts we put, the success of the project depends largely on the
encouragement and guidelines of many others. We take this opportunity to express my
gratitude to the people who have been instrumental in the successful completion of this
project.
We take immense pleasure in thanking Dr. Sanjay kumar for having permitted us to carry
out this project. We would like to express a deep sense of gratitude to Dr. Bharti Sharma,
Head of Department, MCA, for their able guidance and useful suggestions, which helped us
in completing the project in time.
Finally, yet importantly, we would like to express our heartfelt thanks to our parents for their
blessings, our friends for their help and wishes for the successful completion of this project.
ABSTRACT
The Bus Reservation System is a mini project developed in the C programming
language, aimed at simplifying the process of booking bus tickets. In real-life
scenarios, booking tickets manually can be time-consuming and stressful. This
system provides a computerized solution, enabling users to manage reservations
efficiently.
The project includes a Login System for authorized access and offers four main
functionalities: ticket booking, ticket cancellation, bus seat status checking, and
secure exit. Users can select seat numbers for booking, cancel previously
booked tickets, and view the current status of each seat. The system maintains
the state of 30 bus seats and ensures that bookings and cancellations are handled
securely.
This mini project serves as a foundation for understanding file handling, arrays,
conditional logic, and user-defined functions in C. It can be further enhanced by
incorporating file storage, multiple bus schedules, user registration, and a
graphical interface.
INDEX
1. Introduction
2. Software requirement
3. Source Code
4. Output
5. Result
6. Applications
7. Conclusion
8. Reference
Introduction
In today’s fast-paced world, transportation plays a crucial role in connecting people across
cities and states. However, the traditional method of booking bus tickets manually can be
inefficient, time-consuming, and prone to human error. To address this issue, we present a
simple yet effective Bus Reservation System developed using the C programming language.
This project is designed to simulate the process of booking and managing bus tickets in a
computerized environment. The system provides a user-friendly interface that allows users to
log in, book tickets, cancel bookings, and check the current status of bus seats. With a
capacity of 30 seats, the system ensures that no double booking or invalid seat assignment
occurs.
To successfully implement and run the Bus Reservation System, the following software
requirements must be met:
1. Programming Language:
C Programming Language: The core functionality of the project is built using C, as it provides
the necessary control over low-level operations, memory management, and the ability to
implement logic efficiently.
These IDEs provide a user-friendly environment to write, compile, and debug C programs.
3. Operating System:
The project can run on various operating systems, including:
Windows
Linux
macOS
The program uses basic file handling, which is supported across all platforms. However, the
specific IDE might vary in terms of operating system compatibility.
4. Compiler:
C compiler is required to compile the C code. Some common compilers are:
Notepad++ or Sublime Text for writing and editing code, if you are not using an IDE.
Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TOTAL_SEATS 30
#define PASSWORD "admin123"
int main() {
if (!login()) {
printf("Login Failed. Exiting program.\n");
return 0;
}
int choice;
do {
display_menu();
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
book_ticket();
break;
case 2:
cancel_ticket();
break;
case 3:
check_status();
break;
case 4:
printf("Thank you for using the Bus Reservation System.\n");
break;
default:
printf("Invalid choice. Try again.\n");
}
} while (choice != 4);
return 0;
}
// Login function
int login() {
char pass[20];
printf("----- LOGIN -----\n");
printf("Enter Password: ");
scanf("%s", pass);
if (strcmp(pass, PASSWORD) == 0) {
printf("Login Successful.\n\n");
return 1;
} else {
printf("Incorrect Password!\n");
return 0;
}
}
void book_ticket() {
int seat_no;
char name[50];
if (seats[seat_no - 1] == 0) {
seats[seat_no - 1] = 1;
printf("Seat %d successfully booked for %s.\n", seat_no, name);
} else {
printf("Seat %d is already booked.\n", seat_no);
}
}
void cancel_ticket() {
int seat_no;
printf("\n--- Ticket Cancellation ---\n");
printf("Enter seat number to cancel (1-%d): ", TOTAL_SEATS);
scanf("%d", &seat_no);
if (seat_no < 1 || seat_no > TOTAL_SEATS) {
printf("Invalid seat number.\n");
return;
}
if (seats[seat_no - 1] == 1) {
seats[seat_no - 1] = 0;
printf("Seat %d has been cancelled.\n", seat_no);
} else {
printf("Seat %d is not booked yet.\n", seat_no);
}
}
void check_status() {
printf("\n--- Bus Seat Status ---\n");
for (int i = 0; i < TOTAL_SEATS; i++) {
printf("Seat %2d: %s\n", i + 1, seats[i] == 0 ? "Available" :
"Booked");
}
}
void display_menu() {
printf("\n--- Bus Reservation Menu ---\n");
printf("1. Book Ticket\n");
printf("2. Cancel Ticket\n");
printf("3. Check Bus Status\n");
printf("4. Exit\n");
}
Output
Result
The Bus Reservation System was successfully developed and executed using
the C programming language. The system provides a simple, interactive
interface that allows users to:
Check the real-time status of bus seats, showing which are booked and which
are available.
All functionalities were tested and performed as expected. The system ensures
that:
No seat is booked more than once.
Cancellations are only allowed for seats that are already booked.
This project demonstrates the practical application of basic programming constructs such as
arrays, conditionals, loops, and functions in C. It also lays the foundation for building more
advanced systems by introducing key concepts of user interaction and data handling.
Applications
The Bus Reservation System developed in C has several practical applications in
the real world, especially in the transportation and travel sectors. Some key
applications include:
This system serves as the foundational logic for real-time bus ticket booking
systems used by travel agencies and bus operators.
The logic can be used in self-service kiosks installed at bus terminals, allowing
passengers to book and cancel tickets without human assistance.
4. Educational Purposes:
This project is ideal for students and beginners learning programming concepts
such as arrays, conditional statements, loops, functions, and user input
handling.
Small bus operators who currently rely on manual booking processes can use a
system like this to reduce errors and improve efficiency.
6. Prototype for Future Development:
The current system can be enhanced with features like multiple bus schedules,
passenger information storage, payment integration, and database
connectivity for real-world deployment.
Conclusion
https://www.sourcecodester.com/
https://github.com/