In this tutorial, we’ll code the Bus Reservation System Project in C++ in a very easy and understandable way. The Bus Reservation System can be coded using many programming languages, But in this project, we are going to use C++ language as per the demand of students.

What is Bus Reservation System?

As the name suggests Bus Reservation System is software that handles the entire booking data of the Bus. It is fully based on the concept of reserving bus tickets for various destinations. Previously the task of handling the tickets at a time was very difficult, so there was a need for software that can handle all Bus Reservation systems.

Therefore the Bus Reservation System was designed. After the release of this system, the stress and workload of the employee were absolutely finished. It was also time-wasting for the travelers to book a Ticket previously. But now it hardly takes 10 to 15 minutes to book a ticket wherever the passenger is.

Features of Bus Reservation System Project in C++

  • There are no admin rights given, anyone can handle this project.
  • In this project anyone can add buses and do the reservation.
  • The passenger can book the bus only if bus is available.
  • Passengers will be able to check the availability of seats of particular bus, whether seats are reserved or not.
  • Passengers are able to see the status of available buses.

Modules of Bus Reservation System

  • Add Bus
  • Modify Bus.
  • Delete Bus.
  • Search Bus.
  • Reserve Bus Seat.
  • Cancel Booking.

Working of Project

In the zip file, you’ll get an executable .exe file where you can directly run the entire project manually. Now we’ll see the working of the entire application with an explanation.

Main Screen:

When you run the project from any compiler or directly clicking on the executable .exe file you’ll see the following screen shown in the picture.

bus reservation system project in c++

Here, we’ve displayed the menu of Add bus, Bus reservation, Show bus, Buses available, and Exit. If you want to add the new bus which is planned to depart then you should choose the menu as 1. If you’re a passenger and want to reserve the bus seat then choose the menu as 2.

The best feature of this project is that you can see which seat is reserved and which seat is not reserved. To see the reservation data you have to choose the menu as 3. If you want to see the data of available buses then choose the menu option as 4. And the 5th menu option is to exit the project.

Now we’ll see each and every menu in detail.

Add Bus:

By choosing this menu option you’ll be able to add the bus which is going to depart from the particular location. To add a new one you have to choose the menu as 1. After choosing the first menu software ask you to enter some details of the bus which are:

bus reservation system project in c++
  • The Bus number.
  • Name of the driver.
  • Time of Departure.
  • Arrival Time.
  • The location from which bus will departure.
  • Arrival location.

The software will ask you all the above details every time during the addition of a new bus. After entering all the information and successful addition of bus, the software will display one message “Bus added Successfully”. Now in menu option 4, you’ll see the new bus has been added successfully.

Bus Reservation:

This section is the main section of our project where the passenger will be able to reserve the ticket for the available buses. Before reserving the bus tickets you’ve to choose the 4th option and check whether the bus is available or not. If it’s available then this option comes into the picture.

seat reservation project in c++

After choosing this option the software will ask for the following information:

  • Bus number.
  • The seat number which you want to book.
  • Name of the passenger.

After entering the above information correctly the software will show the success message as “Seat Reserved Successfully”.

Note: If the entered seat is reserved by another person already then, the software will show the message as “The seat no is already reserved”. To get rid of this message the next menu comes into the picture. If the seat is already reserved then the software will ask you to enter a different seat, no. If you don’t know which seats are available then, let’s see the working of the 3rd menu.

bus reservation system

Show:

With the help of this option, you’ll get a clear picture of the reservation data of a particular bus. After choosing the 3rd option, the software will ask you to enter the bus number for which you want to see the reservation data. Passengers have to enter the bus number in which they want to do the seat reservation.

show available seats

After entering the bus number the software will show the bus map with the seat numbers. The software will give the information of seats with the name of the person who’s already booked the ticket. If the seat is empty then the software will show it as “Empty”.

By looking at the seat map passenger will get an idea of which seat he has to book in order to travel on that bus. The software will also give the exact number of seats that are available on the bus.

In the above image seat number 1 is booked by Vivek and seat no 5 has been booked by jaydeep. So, passengers will have to book a seat other than 1 and 5.

Now, let’s see the working of menu option 4.

Buses Available:

With the help of this menu, the passenger will be able to check whether the bus is available or not to which passenger wants to travel. To get all the data of available buses the passenger has to choose the option as 4. After choosing the 4th option the software will display all the data of available buses.

buses available

The software will show the following data:

  • Bus number
  • Drivers name
  • Arrival time
  • Departure time
  • Departure location
  • Arrival location

Now let’s see the working of the last menu option of the bus reservation system project in c++ i.e Exit.

Exit:

By choosing the 5th option the bus reservation system project in c++ will be closed.

Download the Project

By clicking the following button you can download the zip file of the project which consists of the source code and the executable .exe file.

Download

If you need a quick project code then please read the following code:

Source Code of Bus Reservation System Project in C++

//Learnprogramo - Programming made simple
#include <conio.h>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <cstdlib>
using namespace std;
static int p = 0;
class a
{
  char busn[5], driver[10], arrival[5], depart[5], from[10], to[10], seat[8][4][10];
public:
  void install();
  void allotment();
  void empty();
  void show();
  void avail();
  void position(int i);
}
bus[10];
void vline(char ch)
{
  for (int i=80;i>0;i--)
  cout<<ch;
}
void a::install()
{
  cout<<"\n\n\n\t\t\tEnter bus no: ";
  cin>>bus[p].busn;
  cout<<"\n\t\t\tEnter Driver's name: ";
  cin>>bus[p].driver;
  cout<<"\n\t\t\tArrival time: ";
  cin>>bus[p].arrival;
  cout<<"\n\t\t\tDeparture: ";
  cin>>bus[p].depart;
  cout<<"\n\t\t\tFrom: ";
  cin>>bus[p].from;
  cout<<"\n\t\t\tTo: ";
  cin>>bus[p].to;
  bus[p].empty();
  p++;
  
  cout<<"\n\t\t\tBus added Sucessfully ";
}
void a::allotment()
{
  int seat;
  char number[5];
  top:
  cout<<"\n\n\n\t\t\tBus no: ";
  cin>>number;
  int n;
  for(n=0;n<=p;n++)
  {
    if(strcmp(bus[n].busn, number)==0)
    break;
  }
  while(n<=p)
  {
    cout<<"\n\t\t\tSeat Number: ";
    cin>>seat;
    if(seat>32)
    {
      cout<<"\n\t\t\tThere are only 32 seats available in this bus.";
    }
    else
    {
    if (strcmp(bus[n].seat[seat/4][(seat%%4)-1], "Empty")==0)
      {
        cout<<"\t\t\tEnter passanger's name: ";
        cin>>bus[n].seat[seat/4][(seat%%4)-1];
        
        cout<<"\t\t\tSeat Reserved Sucessfully ";
        break;
      }
    else
      cout<<"\t\t\tThe seat no. is already reserved.\n";
      }
      }
    if(n>p)
    {
      cout<<"\t\t\tEnter correct bus no.\n";
      goto top;
    }
  }

void a::empty()
{
  for(int i=0; i<8;i++)
  {
    for(int j=0;j<4;j++)
    {
      strcpy(bus[p].seat[i][j], "Empty");
    }
  }
}
void a::show()
{
  int n;
  char number[5];
  cout<<"\t\t\tEnter bus no: ";
  cin>>number;
  for(n=0;n<=p;n++)
  {
    if(strcmp(bus[n].busn, number)==0)
    break;
  }
while(n<=p)
{
  vline('*');
  cout<<"\t\t\tBus no: \t"<<bus[n].busn
  <<"\n\t\t\tDriver: \t"<<bus[n].driver<<"\t\tArrival time: \t"
  <<bus[n].arrival<<"\t\t\tDeparture time:"<<bus[n].depart
  <<"\n\t\t\tFrom: \t\t"<<bus[n].from<<"\t\tTo: \t\t"<<
  bus[n].to<<"\n";
  vline('*');
  bus[0].position(n);
  int a=1;
  for (int i=0; i<8; i++)
  {
    for(int j=0;j<4;j++)
    {
      a++;
      if(strcmp(bus[n].seat[i][j],"Empty")!=0)
      cout<<"\n\t\t\tThe seat no "<<(a-1)<<" is reserved for "<<bus[n].seat[i][j]<<".";
    }
  }
  break;
  }
  if(n>p)
    cout<<"\t\t\tEnter correct bus no: ";
}
void a::position(int l)
{
  int s=0;p=0;
  for (int i =0; i<8;i++)
  {
    cout<<"\n";
    for (int j = 0;j<4; j++)
    {
      s++;
      if(strcmp(bus[l].seat[i][j], "Empty")==0)
        {
          cout.width(5);
          cout.fill(' ');
          cout<<s<<".";
          cout.width(10);
          cout.fill(' ');
          cout<<bus[l].seat[i][j];
          p++;
        }
        else
        {
        cout.width(5);
        cout.fill(' ');
        cout<<s<<".";
        cout.width(10);
        cout.fill(' ');
        cout<<bus[l].seat[i][j];
        }
      }
    }
  cout<<"\n\n\t\t\tThere are "<<p<<" seats empty in Bus No: "<<bus[l].busn;
  }
void a::avail()
{

  for(int n=0;n<p;n++)
  {
    vline('*');
    cout<<"\t\t\tBus no: \t"<<bus[n].busn<<"\n\t\t\tDriver: \t"<<bus[n].driver
    <<"\t\t\tArrival time: \t"<<bus[n].arrival<<"\t\t\tDeparture Time: \t"
    <<bus[n].depart<<"\n\t\t\tFrom: \t\t"<<bus[n].from<<"\t\tTo: \t\t\t"
    <<bus[n].to<<"\n";
    vline('*');
    vline('_');
  }
}
int main()
{
system("cls");
int w;
while(1)
{

  cout<<"\n\n\n\n\n";
  
  cout<<"\t\t\tBus Reservation System Project in C++\n\n";
  
  cout<<"\t\t\t1.Add Bus\n\t\t\t"
  <<"2.Bus Reservation\n\t\t\t"
  <<"3.Show\n\t\t\t"
  <<"4.Buses Available. \n\t\t\t"
  <<"5.Exit";
  cout<<"\n\t\t\tEnter your choice:-> ";
  cin>>w;
  switch(w)
  {
    case 1:  bus[p].install();
      break;
    case 2:  bus[p].allotment();
      break;
    case 3:  bus[0].show();
      break;
    case 4:  bus[0].avail();
      break;
    case 5:  exit(0);
  }
}
return 0;
}

Steps to Run the Project

  1. Extract the Downloaded Zip file or copy the above source code of bus reservation system project in c++.
  2. Open the file using C++ Compiler such as Dev C++ etc.
  3. Paste the source code and save the file in any of the computer locations.
  4. Compile the project using compile option.
  5. There is no error in the source code, if found then correct it.
  6. Now run the project.
  7. The executable .exe file will be generated in the location you choose.

Summary:

In this way, we’ve created and executed the Bus Reservation System Project in C++. If you have any doubt then please feel free to contact us. We’ll solve your doubts as soon as possible.

Thanks and HAPPY CODING 🙂

Also Read: