You are on page 1of 70

Mini Project Report

On

RAILWAY RESERVATION SYSTEM.


Submitted By:
IZHAN PARVEZ

In partial fulfillment for the award of the degree


of

B.C.A DEGREE
B.
INTERNATIONAL INSTITUTE OF MANAGEMENT
MEDIA & I.T

( 2023)
Final Year Students

(Paper Code: BCA-307)

BACHELOR OF COMPUTER
APPLICATION

PROGRAM (BCA)

INTERNATIONAL INSTITUTE OF
MANAGEMENT MEDIA & I.T. (IIMMI)
Name of Student : IZHAN PARVEZ

Father‘s Name : PARVEZ AKHTAR

Email ID of Student : khanizhan005@gmail.com

Course : B.C.A

Project Code No:-


A MAJOR PROJECT REPORT
ON
“------------------------------------------------------------------”

Submitted in partial fulfillment for the award of the degree of Bachelor of


Computer Application

BCA 3rd Year


(Session: 2019 – 2022)

Under the guidance of: - Submitted By:-

<Name of Guide> <Name of student>


<Designation> Enroll No:-

DECLARATION
I hereby declare that the project work entitled
“…Railway Reservation
System………………………………………”submitted for the

Bachelor of Computer Application (BCA) is my original


work carried
out by me under the guidance of < Project Mentor> for the partial

fulfillment of the award of the degree of the Bachelor of

Computer Application.

The matter embodied in this report has not submitted anywhere else

for the award of any other degree/diploma.


(Student’s Full Signature)

SUPERVISOR’S PROFILE

1. Name :
2. Designation :
3. Qualification : :
4. Area of Specialization : :
5. Experience : :
6. Office Name &Address : :
7. Contact No. :
8. E_Mail :

I am willing to supervise

Mr. / Ms. < Student’s Name> Enroll No.

For Project of BCA (3 Year course)

Date:

Signature of Guide
CERTIFICATE OF THE GUIDE

Mentor / Guide Name: <Guide Name>

Designation:

Working Place:

This is to certify that the project report entitled

“______________________________________________________________” has been prepared by Mr.

/ Ms. <student’s Name> under my supervision and guidance, for the fulfillment of Bachelors of

Computer Application.

His / Her field work is satisfactory.

Date:

Signature of Guide
ACKNOWLEDGMENT

I take this occasion to thank God, almighty for

blessing us with his grace and taking our endeavor to a

successful culmination. I extend my sincere and heartfelt

thanks to our esteemed guide, my parents for providing me

with the right guidance and advice at the crucial junctures

and for showing me the right way. I extend my sincere

thanks to our respected Head of the division Mrs.SWATI

MADAM, for allowing us to use the facilities available. I

would like to thank the other faculty members also, at this

occasion. Last but not the least, I would like to thank my

friends and family for the support and encouragement they

have given me during the course of our work.

IZHAN PARVEZ
Railway Reservation System Project in C++
In this tutorial, we’ll code the Railway Reservation
System Project in C++ in a very easy and understandable
way. The Railway 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.
Table of Contents
What is Railway Reservation System?
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#What_is_Railway_Reservation_System)
Features of Railway Reservation System Project in C++
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Features_of_Railway_Reservation_System_Projec
t_in_C)
Modules of Railway Reservation System
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Modules_of_Railway_Reservation_System)
Working of Project (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Working_of_Project)
Main Screen: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Main_Screen)
View Information: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#View_Information)
Book Ticket: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Book_Ticket)
Cancel Ticket: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Cancel_Ticket)
Admin: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-
code/#Admin)
Exit: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-code/#Exit)
Download the Project
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Download_the_Project)
Source Code of Railway Reservation System Project in
C++ (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-
code/#Source_Code_of_Railway_Reservation_System_Pr
oject_in_C)
Steps to Run the Project
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Steps_to_Run_the_Project)
Summary: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Summary)
What is Railway Reservation System?
As the name suggests Railway Reservation System is
software that handles the entire booking data of the
Railway. It is fully based on the concept of reserving train
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 Railway
Reservation System.
Therefore the Railway 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 (https://www.makemytrip.com/railways/) wherever the passenger is.
Features of Railway Reservation System Project in C++
We have created separate logins for the passengers as well as admin, in which the
admin login is password protected.
In this project, the admin can add, update, delete and create the trains.
The passenger can book the train only if the train is added by the admin.
Passengers are able to see the actual data of available trains so that they can
choose which they want.
The entire rights are given to the admin adding, modifying and deleting the train.
This project use concept of file handling to store the booking data.
Cancelling the ticket is an main feature of this project.
Admin is able to change the password of login.
Modules of Railway Reservation System
Add Train
Modify Train

Delete Train

Search Train

Book Train

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.

We’ve displayed the menu of View information, Book the


ticket, Cancel ticket, Admin, and Exit. If you want to see the
details of all available trains then your choice will be 1. Similarly
2 for booking the ticket, 3 for cancellation of ticket. If you are
an admin you should give choice as 4.
Play
Unmute
Loaded: 7.95%
Remaining Time -7:31
Auto(360pLQ)
Fullscreen
Train Reservation Project in Java using JSP, Servlet and MYSQL
(https://humix.com/redirect?url=https%3A%2F%2Fcodebun.co
m%2Fhumix%2Fvideo%2F10c3e8519aa74c9f6617fecbe0eeeb5
227ba903df21b5ab0bd6132a8bf74d7c3)
Now we’ll see each and every menu in detail.
View Information:
In this option, the user will be able to see all the details of the
available trains. The details of all the trains will be displayed
here which are stored in the file name “train_details”. Only the
admin can add the train details, no one other than the admin
can do operations on train details.
The passengers did not require additional sign-in to book the
train. He or she’ll be able to book the train directly.
When the user chooses the option as 1 then the following
screen will appear:

The above screen contains all the details of trains. If you want
to return to the main menu then press 1 or press any key to
exit the application.
Book Ticket:
In this section, passengers will be able to book the tickets.
When the Passenger chooses option 2 then the following
screen will appear.

Skip to content (https://learnprogramo.com/railway-


reservation-system-project-in-c-download-with-source-
code/#content)
(https://learnprogramo.com/)
Railway Reservation System Project in C++ [Download With
Source Code]
In this tutorial, we’ll code the Railway Reservation System
Project in C++ in a very easy and understandable way. The
Railway 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.
Table of Contents
What is Railway Reservation System?
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#What_is_Railway_Reservation_System)
Features of Railway Reservation System Project in C++
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Features_of_Railway_Reservation_System_Project_in_C
)
Modules of Railway Reservation System
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Modules_of_Railway_Reservation_System)
Working of Project (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Working_of_Project)
Main Screen: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-
code/#Main_Screen)
View Information: (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#View_Information)
Book Ticket: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-code/#Book_Ticket)
Cancel Ticket: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-
code/#Cancel_Ticket)
Admin: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-code/#Admin)
Exit: (https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-code/#Exit)
Download the Project (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Download_the_Project)
Source Code of Railway Reservation System Project in C++
(https://learnprogramo.com/railway-reservation-system-
project-in-c-download-with-source-
code/#Source_Code_of_Railway_Reservation_System_Project_
in_C)
Steps to Run the Project (https://learnprogramo.com/railway-
reservation-system-project-in-c-download-with-source-
code/#Steps_to_Run_the_Project)
Summary: (https://learnprogramo.com/railway-reservation-
system-project-in-c-download-with-source-code/#Summary)
What is Railway Reservation System?
As the name suggests Railway Reservation System is software
that handles the entire booking data of the Railway. It is fully
based on the concept of reserving train 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 Railway Reservation System.
Therefore the Railway 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
(https://www.makemytrip.com/railways/) wherever the
passenger is.
Features of Railway Reservation System Project in C++
We have created separate logins for the passengers as well as
admin, in which the admin login is password protected.
In this project, the admin can add, update, delete and create
the trains.
The passenger can book the train only if the train is added by
the admin.
Passengers are able to see the actual data of available trains so
that they can choose which they want.
The entire rights are given to the admin adding, modifying and
deleting the train.
This project use concept of file handling to store the booking
data.
Cancelling the ticket is an main feature of this project.
Admin is able to change the password of login.
Modules of Railway Reservation System
Add Train
Modify Train
Delete Train
Search Train
Book Train
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.

We’ve displayed the menu of View information, Book the ticket, Cancel ticket,
Admin, and Exit. If you want to see the details of all available trains then your
choice will be 1. Similarly 2 for booking the ticket, 3 for cancellation of ticket. If
you are an admin you should give choice as 4.
Play
Unmute
Loaded: 7.95%
Remaining Time -7:31
Auto(360pLQ)
Fullscreen
Train Reservation Project in Java using JSP, Servlet and MYSQL
(https://humix.com/redirect?url=https%3A%2F%2Fcodebun.com%2Fhumix%2Fvi
deo%2F10c3e8519aa74c9f6617fecbe0eeeb5227ba903df21b5ab0bd6132a8bf74d
7c3)
Now we’ll see each and every menu in detail.
View Information:
In this option, the user will be able to see all the details of the available trains. The
details of all the trains will be displayed here which are stored in the file name
“train_details”. Only the admin can add the train details, no one other than the
admin can do operations on train details.
The passengers did not require additional sign-in to book the train. He or she’ll be
able to book the train directly.
When the user chooses the option as 1 then the following screen will appear:
The above screen contains all the details of trains. If you want to return to the
main menu then press 1 or press any key to exit the application.
Book Ticket:
In this section, passengers will be able to book the tickets. When the Passenger
chooses option 2 then the following screen will appear.

After entering the choice as 2, the software will ask the passenger to enter the
following information:
No of tickets which passenger wants to book.
Train number.
Date on which passenger want to travel.
Name of the passengers.
Contact Number of each passenger.
The software will ask for the above details for each and every passenger. Suppose
passengers enter no of tickets as 2 then the software’ll ask for the above details
of two passengers. After entering the details, the software will automatically
allocate the seat number to the passenger.
Cancel Ticket:
If the passenger’s mind changed and he wants to cancel the ticket urgently then
the software also has the facility of canceling the ticket on the spot. To cancel the
ticket, the passenger should choose option 3.
After choosing option 3, the following screen will appear:

The ticket will be canceled only on the basis of the


contact number. If the passenger’s contact number
matches with the number which he entered while
booking the ticket.
The success message will appear after the cancellation of
the ticket.
Admin:
The Admin is also called the heart of the software or
project because he’s the only one who can handle the
entire Train Booking System. We’ve given all the read,
write, update and delete permissions only to the admin.
If the user is admin then he should enter the choice as 4.
After entering the choice as 4 the following admin panel
will appear:

The admin panel is password-protected so, the user


other than admin will not be able to access the
dashboard. The password for admin login is “1234567”.
After entering the correct password, the following
dashboard will be visible to the admin.

Now we’ll discuss each and every operation which is


present on the admin dashboard.
1. View Passengers:
In this menu option, all the booking details of the
passengers will be displayed with the train number and
seat number. Press 1 if you want to access the main
menu or press 0 for a back operation.
2. Add Train:
Admin will be able to add the trains which are ready to
travel on a specific date. While adding the train, the
software will ask each and every following detail of the
train:
Serial number.
Train number.
Name of the Train.
Start Place.
Destination Place.
Price of the Ticket.
Number of available Seats.
Time of Departure.
And after entering all details press 0 for no or press 1 for
confirming train.
3. Delete Train:
If the admin wants to delete the train due to some
issues, then the admin will be able to instantly delete the
train by choosing this option. Trian will be deleted only
on the basis of train number.
4. Back:
This option will be chosen if the admin wants to access
the main menu.
Exit:
By choosing the 5th option railway 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 (https://learnprogramo.com/wp-
content/uploads/2021/08/railway-management-
system.zip)
If you need quick project code then please read the
following code:
Source Code of Railway Reservation System Project in
C++
C++
1
//------------------
2
//---------------------------rail way reservation project by using c
programming language--------------------------
3
//---------------------------------------header file start--------------------------------
---------
4
#include<stdio.h>
5
#include<windows.h>
6
#include<stdlib.h>
7
#include<conio.h>
8
#include<time.h>
9
#include<string.h>
10
//---------------------------------------header file close--------------------------------
-----------
11
//---------------------------------------user define function start--------------------
--------------
12
void viewinfo();
13
void bookticket();
14
void cancelticket();
15
void admin();
16
void password();
17
void viewpassenger();
18
void addtrain();

void dlttrain();
20
void awrite();
21
void aread();
22
void bookticket_write();
23
void viewpassengers_read();
24
//-----------------------------------------user define function close-----------------
------------------
25
//-----------------------------------------structure start--------------------------------
--------------
26
struct adddata
27
{
28
char si[10];
29
char train_number[10];
30
char train_name[20];
31
char start[10];
32
char destination[10];
33
char price[10];
34
int seat;
35
char time[10];
36
} add[1000];
37
struct bookticket
38
{
39
char train_number[20];
40
char name[20];
41
char phone[20];
42
char date[20];
43
int seat;
44
}book[1000];
45
//---------------------------------------structure close----------------------------------
------------
46
//---------------------------------------global variable----------------------------------
------------
47
int k=0,u=0;
48
char trn_nmbr[100],name[100],phn[100];
49
//---------------------------------------main function start----------------------------
--------------
50
int main()
51
{
52
aread();
53
viewpassengers_read();
54
system("COLOR 0f");
55
int ch;
56
time_t currentTime;
57
time(&currentTime);
58
printf("\n\t\t\t %s\n",ctime(&currentTime));
59
60
printf("\n\t\t\t*********\n");
61
printf("\t\t\t*RAILWAY RESERVATION SYSTEM*\n");
62
printf("\t\t\t*********\n");
63
printf("\n\t\t\t<<<<<<<<<<WELCOME USERS>>>>>>>>>>\n");
64
printf("\n\n\t\t\t\t MENU\n");
65
printf("\t\t\t **");
66
printf("\n\t\t\t[1] VIEW INFORMATION\n");
67
printf("\n\t\t\t[2] BOOK TICKET\n");
68
printf("\n\t\t\t[3] CANCEL TICKET\n");
69
printf("\n\t\t\t[4] ADMIN");
70
printf("\n\n\t\t\t[5] EXIT\n");
71
printf("\n\t\t\t********");
72
printf("\n\t\t\t********");
73
printf("\n\t\t\tENTER YOUR CHOICE: ");
74
scanf("%d",&ch);
75
switch(ch)
76
{
77
case 1:
78
viewinfo();
79
break;
80
case 2:
81
bookticket();
82
break;
83
case 3:
84
cancelticket();
85
break;
86
case 4:
87
password();
88
break;
89
case 5:
90
system("cls");
91
printf("\n\t\t\t =========================================\n");
92
printf("\t\t\t *RAILWAY RESERVATION SYSTEM*\n");
93
printf("\t\t\t ===============================================\n");
94
printf("\n\n\t\t\tBMROUGHT TO YOU BY\n\n");
95
printf("\t\t\t\t*Learnprogramo*\n");
96
getch();
97
exit(0);
98
break;
99
default:
100
system("cls");
101
printf("\n\t\t\t==============================================\n");
102
printf("\t\t\t *RAILWAY RESERVATION SYSTEM*\n");
103
printf("\t\t\t ==============================================\n");
104
printf("\n\n\t\t\t<<<<<<<<YOU ENTERED WRONG CHOICE>>>>>>>>\n");
105
printf("\t\t\t<<<<<<<<PLEASE ENTER RIGHT THING>>>>>>>>\n");
106
getch();
107
system("cls");
108
main();
109
}
110
return 0;
111
}
112
//---------------------------------------main function close-----------------------------------------
---------
113
//---------------------------------------book ticket function-----------------------------------------
------
114
void bookticket()
115
{
116
int c,j,n,i,found=-1;
117
char v,train_number[10];
118
system ("cls");
119
aread();
120
printf("\n\n\t\t\t============================================");
121
printf("\n\t\t\t**RAILWAY RESERVATION SYSTEM**\n");
122
printf("\t\t\t==================================================");
123
printf("\n\n\t\t\thow many ticket do you want to buy: ");
124
scanf("%d",&n);
125
for(j=u;j<u+n;j++)
126
{
127
printf("\n\n\t\t\tEnter train number: ");
128
scanf("%s", book[j].train_number);
129
for(i=0;i<k;i++)
130
{
131
if(strcmp(book[j].train_number,add[i].train_number)==0)
132
{
133
if(add[i].seat==0)
134
{
135
printf("\n\n\t\t\tnot available seat");
136
137
getch();
138

system("cls");
139
main();
140
}
141
else
142
{
143
found=1;
144
printf("\n\t\t\tenter book %d no ticket: ",j+1);
145
printf("\n\t\t\tenter date: ");
146
scanf("%s",book[j].date);
147
printf("\n\t\t\tenter your name: ");
148
scanf("%s",book[j].name);
149
printf("\n\t\t\tenter your phone number: ");
150
scanf("%s",book[j].phone);
151
printf("\n\t\t\tseat number : %d",add[i].seat );
152
book[j].seat=add[i].seat;
153
bookticket_write();
154
add[i].seat--;
155
awrite();
156
}
157
}
158
}
159
if(found==-1)
160
{
161
printf("\n\n\t\t\ttrain not found!!!");
162
getch();
163
system("cls");
164
main();
165
}
166
}
167
u=j;
168
bookticket_write();
169
printf("\n\n\t\t\tenter '1' for main menu & press any key to exit: ");
170
scanf("%d",&c);
171
if(c==1)
172
{
173
system("cls");
174
main();
175
}
176
if(c!=1)
177
{
178
exit;
179
}
180
}
181
//---------------------------------------cancel ticket function---------------------------------------
------
182
void cancelticket()
183
{
184
viewpassengers_read();
185
char pnnmbr[100];
186
int location = -1,e;
187
printf ("\n\n\t\t\tenter phone number: ");
188
scanf ("%s",pnnmbr);
189
for (e=0;e<u;e++)
190
{
191
if (strcmp(pnnmbr,book[e].phone)==0)
192
{
193
location=e;
194
break;
195
}
196
}
197
if (location==-1)
198
{
199
printf ("\n\n\t\t\t<<<<<<<<<<<<<<Data Not Found>>>>>>>>>>>>>>>>> \n");
200
getch();
201
system("cls");
202
main();
203
}
204
else
205
{
206
for (e=location;e<u;e++)
207
{
208
strcpy(book[e].date,book[e+1].date);
209
strcpy(book[e].train_number,book[e+1].train_number);
210
strcpy(book[e].name,book[e+1].name);
211
strcpy(book[e].phone,book[e+1].phone);
212
bookticket_write();
213
}
214
u--;
215
bookticket_write();
216
printf("\n\n\t\t\t<<<<<<<<<<<<<<<ticket cancelled successfully>>>>>>>>>>>>");
217
getch();
218
system("cls");
219
main();
220
}
221
}
222
//-------------------------------------admin portal function----------------------------------------
223
void admin()
224
{
225
int chhh;
226
system("cls");
227
printf("\n
=================================================================="
);
228
printf("\n ****RAILWAY RESERVATION SYSTEM*******");
229
printf("\n
===================================================================
=");
230
printf("\n\n");
231
printf(" <<<<<<<<<<<<<<<WELCOME_ADMIN>>>>>>>>>>>>>>>\n");
232
printf("\n\n");
233
printf(" ********\n");
234
printf(" CHOOSE YOUR OPERATION \n");
235
printf(" --------------------------------\n");
236
printf(" [1] VIEW PASSENGERS \n");
237
printf(" [2] ADD TRAIN \n");
238
printf(" [3] DELETE TRAIN \n");
239
printf(" [4] BACK \n");
240
printf(" \n");
241
printf(" ********\n\n");
242
printf(" **************\n");
243
printf("\n\t\tENTER YOUR CHOICE: ");
244
scanf("%d",&chhh);
245
switch(chhh)
246
{
247
case 1:
248
viewpassenger();
249
break;
250
case 2:
251
addtrain();
252
break;
253
case 3:
254
dlttrain();
255
break;
256
case 4:
257
system("cls");
258
getch();
259
main();
260
break;
261
default:
262
getch();
263
printf("\n\t\t\tyou entered wrong KEY!!!!");
264
getch();
265
system("cls");
266
main();
267
}
268
getch();
269
}
270
//-----------------------------password function----------------------------------
271
void password()
272
{
273
int number=1234567;
274
int pass;
275
printf("\n\t\t\tenter password: ");
276
scanf("%d",&pass);
277
if(pass==number)
278
{
279
printf("\n\n\t\t\t<<<<<login successfully>>>>>");
280
getch();
281
system("cls");
282
admin();
283
}
284
else
285
{
286
printf("\n\n\t\t\t\t ERROR!!!!!");
287
printf("\n\n\t\t\t<<<<<<<<wrong password>>>>>>>>");
288
getch();
289
system("cls");
290
main();
291
}
292
}
293
//------------------------------------delete train function-------------------------------------------
---

294
void dlttrain()
295
{
296
aread();
297
char train[100];
298

int location = -1,f;


299
printf ("\n\n\tenter train number: ");
300
scanf ("%s",train);
301
for (f=0;f<k;f++)
302
{
303
if (strcmp(train,add[f].train_number)==0)
304
{
305
location=f;
306
break;
307
}
308
}
309
if (location==-1)
310
{
311
printf ("\n\n\t<<<<<<<<<<<<<<Data Not Found>>>>>>>>>>>>>>>>>
\n");
312
getch();
313
system("cls");
314
admin();
315
}
316
else
317
{
318
for (f=location;f<k;f++)
319
{
320
strcpy(add[f].si,add[f+1].si);
321
strcpy(add[f].train_number,add[f+1].train_number);
322
strcpy(add[f].train_name,add[f+1].train_name);
323
strcpy(add[f].start,add[f+1].start);
324
strcpy(add[f].destination,add[f+1].destination);
325
strcpy(add[f].price,add[f+1].price);
326
strcpy(add[f].time,add[f+1].time);
327
awrite();
328
}
329
k--;
330
awrite();
331
printf("\n\n\t<<<<<<<<<<<<<train deleted
successfully>>>>>>>>>>>>>");
332
getch();
333
system("cls");
334
admin();
335
}
336
}
337
//--------------------------------------view passengers function---------------------
-------------------
338
void viewpassenger()
339
{
340
int a,j;
341
system("cls");
342
viewpassengers_read();
343
printf("\n\t\t\t **************");
344
printf("\n\t\t\t ****RAILWAY RESERVATION SYSTEM****");
345
printf("\n\t\t\t **************");
346
printf("\n\n\t\t\ttrain number\t\tname\t\tphone
number\t\tdate\t\tseat\n");
347
printf("\n\t\t\t******************\n");
348
for(j=0;j<u;j++)
349
{
350
printf("\n\t\t\t%s\t\t\t%s\t\t%s\t\t%s\t%d",book[j].train_number,book
[j].name,book[j].phone,book[j].date,book[j].seat);
351
book[j].seat++;
352
}
353
printf("\n\t\t\t******************\n");
354
printf("\n\n\t\t\tenter '1' for main menu & enter '0' for back: ");
355
scanf("%d",&a);
356
if(a==1)
357
{
358
system("cls");
359
main();
360
}
361
if(a==0)
362
{
363
system("cls");
364
admin();
365
}
366
}
367
//--------------------------------------add train function-------------------------------
-------------
368
void addtrain()
369
{
370
system("cls");
371
int ch;
372
aread();
373
int i,a;
374
printf("\n\t\t **************");
375
printf("\n\t\t ****RAILWAY RESERVATION SYSTEM****");
376
printf("\n\t\t **************");
377
printf("\n\n\t\t\thow many trains do you want to add: ");
378
scanf("%d",&a);
379
for(i=k;i<k+a;i++)
380
{
381
printf("\n\t\t\tenter %d train details: ",i+1);
382
printf("\n\t\t\tenter serial number: ");
383
scanf("%s",add[i].si);
384
printf("\n\t\t\tenter train number: ");
385
scanf("%s",add[i].train_number);
386
printf("\n\t\t\tenter train name: ");
387
scanf("%s",add[i].train_name);
388
printf("\n\t\t\tenter start place: ");
389
scanf("%s",add[i].start);
390
printf("\n\t\t\tenter destination place: ");
391
scanf("%s",add[i].destination);
392
printf("\n\t\t\t enter price: ");
393
scanf("%s",add[i].price);
394
printf("\n\t\t\t enter seat: ");
395
scanf("%d", & add[i].seat);
396
printf("\n\t\t\t enter time: ");
397
scanf("%s",add[i].time);
398
}
399
printf("\n\n\t\t\tconfirm train: (y=1/n=0):- ");
400
scanf("%d",&ch);
401
if(ch==1)
402
{
403
awrite();
404
k=i;
405
awrite();
406
system("cls");
407
printf("\n\n\t\t\t**************");
408
printf("\n\t\t\t****RAILWAY RESERVATION SYSTEM****");
409
printf("\n\t\t\t**************");
410
printf("\n\n");
411
printf("\n\t\t\t\t **********");
412
printf("\n\t\t\t\t *<<<<<train add successfully>>>>>*");
413
printf("\n\t\t\t\t **********");
414
getch();
415
system("cls");
416
main();
417
}
418
if(ch==0)
419
{
420
system("cls");
421
admin();
422
}
423
if((ch!=1)&&(ch!=0))
424
{
425
system("cls");
426
main();
427
}
428
}
429
//-----------------------------------view information function-----------------------
---------------
430
void viewinfo()
431
{
432
int ch,i;
433
system("cls");
434
aread();
435
printf("\n\t\t **************");
436
printf("\n\t\t ****RAILWAY RESERVATION SYSTEM****");
437
printf("\n\t\t **************");
438
printf("\n\n\n SI\ttrain number\ttrain name\tstart place\tdestination
place\tprice\tseat\ttime\n\n");
439
for(i=0;i<k;i++)
440
{
441
printf("
%s\t%s\t\t%s\t\t%s\t\t%s\t\t\t%s\t%d\t%s\n",add[i].si,add[i].train_nu
mber,add[i].train_name,add[i].start,add[i].destination,add[i].price,add[i
].seat,add[i].time);
442
}
443
printf(" *******************\n");
444
printf("\n\t\t\tpress '1' for main menu & press any key for exit: ");
445
scanf("%d",&ch);
446
switch(ch)
447
{
448
case 1:
449
system("cls");
450
main();
451
break;
452
default:
453
exit(0);
454
}
455
}
456
//------------------------------------------book ticket file start------------------------
-----------------
457
void bookticket_write()
458
{
459
FILE *booklist;
460
booklist=fopen("booklist.txt","w");
461
fwrite(&book,sizeof(book),1,booklist);
462
fclose(booklist);
463
FILE *booklistreport;
464
booklistreport=fopen("booklistreport.txt","w");
465
fwrite(&u,sizeof(u),1,booklistreport);
466
fclose(booklistreport);
467
}
468
void viewpassengers_read()
469
{
470
FILE *booklist;
471
booklist=fopen("booklist.txt","r");
472
fread(&book,sizeof(book),1,booklist);
473
fclose(booklist);
474
FILE *booklistreport;
475
booklistreport=fopen("booklistreport.txt","r");
476
fread(&u,sizeof(u),1,booklistreport);
477
fclose(booklistreport);
478
}
479
//-----------------------------------------add train file start----------------------------
-----------------------
480
void awrite()
481
{
482
FILE *train_details;
483
train_details = fopen("train_details.txt","w");
484
fwrite(&add,sizeof(add),1,train_details);
485
fclose(train_details);
486
FILE *train_report;
487
train_report = fopen("train_report.txt","w");
488
fwrite(&k,sizeof(k),1,train_report);
489
fclose(train_report);
490
}
491
void aread()
492
{
493
FILE *train_details;
494
train_details = fopen("train_details.txt","r");
495
fread(&add,sizeof(add),1,train_details);
496
fclose(train_details);
497
FILE *train_report;
498
train_report = fopen("train_report.txt","r");
499
fread(&k,sizeof(k),1,train_report);
500
fclose(train_report);
501
}
502
//----------------------------------------------------file close-----------------------------
-----------------
503
//----------------------------------------------------program close----------------------
------------------
Steps to Run the Project
Extract the Downloaded Zip file or copy the above source code.
Open the file using C++ Compiler such as Dev C++ etc.
Paste the source code and save the file in any of the computer
locations.
Compile the project using compile option.
There is no error in the source code, if found then correct it.
Now run the project.
The executable .exe file will be generated in the location you choose.
Summary:
In this way, we’ve created and executed the Railway Reservation
System Project in C++. If you have any doubt then please feel free to
contact us (https://learnprogramo.com/contact/). We’ll solve your
doubts as soon as possible.
Thanks and HAPPY CODING �
Also Read:
50+ Interesting C Projects. (https://learnprogramo.com/50-interesting-
programming-c-projects-download-with-source-code/)
25+ C++ Projects. (https://learnprogramo.com/25-best-c-projects-for-
class-12th-engineering-with-source-code/)
Library Management System Project in C++.
(https://learnprogramo.com/library-management-system-project-in-c-
download-with-source-code/)
Airline Reservation System Project in C++.
(https://learnprogramo.com/airline-reservation-system-project-in-cpp-
download-with-source-code/)

You might also like