Airline Reservation System
Airline Reservation System
MINI-PROJECT S1
SRMIST CSE AI ML
18CSS101J-NALLARASAN SIR
MINI PROJECT - C LANGUAGE
SRMIST 1ST YEAR – CSE AI & ML (S1)
PROGRAMMING FOR PROBLEM-SOLVING
Introduction
Originally, the C language is developed from two previous languages, BCPL and
B. BCPL which were developed in 1967 by Martin Richards as a language for wringing
operating systems and compilers. C was evolved from B by Dennis Ritchie at Bell
Laboratories and it was implemented in 1972. It initially became widely known as the
development language of the UNIX operating system. Lots of today’s leading operating
systems are written in C and C++. C language is mostly hardware independent as it is
possible to write C programs that are portable to most computers.
Why we use c language C has been used successfully for each kind of programming
problem thinkable from operating systems to spreadsheets to expert systems - and efficient
compilers are accessible for machines ranging in power from the Apple Macintosh to the
Cray supercomputers. the largest measure of C's success appears to be based on strictly
sensible considerations:
the ease with that applications can be optimized by hand-coding isolated procedures;
Our main aim is to write a program to assign seats on each flight of the airlines
only place (capacity: 15 seats).
The program should never assign a seat that is already assigned. If there’s no seat
available, then print the message " the flight is full ".
After the flight is full and someone wants to cancel the booking, it is displaying enter you’re
the passport number you want to cancel it so after the passenger cancels it, the system
directly free that place if someone wants to book that seat.
Moreover, the system should bring a boarding pass indicating the persons' name, passport
number, and seat number as each seat is assigned, set the corresponding elements of the
array to 1 to indicate that the seat is no longer available.
FLOW CHART
1.Main menu
Start
Declare Choice
Print
“welcome to
our airlines”
Print
“Airline Seat
Selection
1.Reservation
2.Cancel
3.Dispaly layout
4.Exit
accept choice
NO NO
NO NO PRINT
choice = 2
choice = 1 choice = 3 choice = 4 "INVALID
CH"
YES
YES YES YES
R C D E
STOP
When the program is started, the user will direct to the main menu. The user will be
required to select one of the four options.
2.Reservation and 3.cancel functions
Declare seats = 10
,firstname,lastname Declare
,passport.no passport.no
Print "Enter
your
Sorry no NO passport.no:"
seats If seats <10
available
Accept passport
YES number
Seats = seats+1
YES print"not
Enter firstname End of records
found"
Enter lastname
Enter
passport.no
NO
Accept NO passport.no=
Read next record
Firstname,Lastname, record_passport.no?
passport.no
print
"booked Delete record
successfully"
YES
RTN
RTN
These are the flowcharts for the reservation and cancel functions
4.Displaying Function.
NO
End of records? Display seats read next record
YES
RTN
Begin
Declare Choice Repeat
repeat
display “welcome to our airlines”
display “Airline Seat Selection
1.Reservathion
2.Cancel
3.Dispaly layout
4.Exit
Enter your choice”
Accept choice
If (choice = 1)
Call R ()
Else
If (choice = 2)
Call C ()
Else
If (choice = 3)
Call D ()
Else
If (choice = 4)
Call E ()
Else
Print “Invalid choice”
End-If
End-If
End-If
End-If
End
Function reservation ()
Accept name
Accept email
IF (seats >15)
ELSE
IF
(Seats <=15)
END-IF
END-IF
END-FOR
Return
Function Cancel ()
Delete record
Return
END-IF
END-do
Return
Display Record
End -do
Return
C source code
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
struct srm_airline
{ char passport[6];
char name[15];
int seat_num;
char email[15];
struct srm_airline*following;
*begin,*stream;
struct srm_airline*dummy;
void main()
int choice;
begin=stream=NULL;
int num=1;
do
{printf("\n\n\t\t *****************************************");
printf("\n\n\t\t 1.RESERVATION");
printf("\n\n\t\t 2.CANCEL");
printf("\n\n\t\t 4.EXIT");
scanf("%d",&choice); fflush(stdin);
system("cls");
switch(choice)
case 1:
reserve(num);
num++ ;
break;
case 2:
cancel();
break;
case 3:
display();
break;
case 4:
{ savefile();
break;
default:
getch();
//*GOOD LUCK**//
void details()
{
printf("\n\t Greetings!");
gets(stream->passport); fflush(stdin);
gets(stream->passport); fflush(stdin);
gets(stream->name); fflush(stdin);
gets(stream->email); fflush(stdin);
//*GOOD LUCK**//
void details();
void reserve(int x)
{ stream=begin;
if (begin==NULL)
//First User//
details();
stream->following=NULL;
stream->seat_num=x;
return;
else if(x>15)
return;
else
{
//next User
while(stream->following)
stream=stream->following;
stream=stream->following;
details();
stream->following=NULL;
stream->seat_num=x;
return;
//*GOOD LUCK**//
void savefile()
{ FILE*fpointer=fopen("airline records","w");
if (!fpointer)
return;
stream=begin;
while (stream)
{ fprintf(fpointer,"%-6s",stream->passport);
fprintf(fpointer,"%-15s",stream->name);
fprintf(fpointer,"%-15s",stream->email);
stream=stream->following;
fclose(fpointer);
}
//*GOOD LUCK**//
void display()
{ stream=begin;
while(stream)
printf("\n Name:%-15s",stream->name);
printf("\n\n++=============================================================++");
stream=stream->following;
//*GOOD LUCK**//
void cancel()
stream=begin;
system("cls");
char passport[6];
gets(passport); fflush(stdin);
gets(passport); fflush(stdin);
if (strcmp(begin->passport,passport)==0)
dummy=begin;
begin=begin->following;
free(dummy);
return;
}
while(stream->following)
if(strcmp(stream->following->passport,passport)==0)
dummy=stream->following;
stream->following=stream->following->following;
free(dummy);
getch();
return;
stream=stream->following;
//*GOOD LUCK**/
REPORT
Main Menu
When the program is executed, the user will be directed to the main menu interface. The
program is introduced with a few lines of text. Then four selections are made for the user
as the user can choose to reserve, cancel, display or exit the program.
Invalid value
. If the user accidentally enters an invalid input, an interface will be shown to notify the
user to choose again and it notify the user again to enter from 1-4.
reservation function
The program is asking the user to enter passport number, name, and email address to
reserve a seat for the user and the seat cannot be book for anyone else.
As shown in the interface the seat reservation has been booked successfully, after the user
has entered the details.
15 is the maximum seat number
After registering 15 users in the system now the flight is supposed to be full and cannot
except anymore.
The system will pop out to notify the user that there’s no seat available, the flight
contains only 15 seat after that it is displaying it is full sorry we cannot register anymore.
cancel function
After the passenger entered 3 and want to cancel the record, after that, the program
requires the user to enter which passport number to delete it. For example, that Person A
registered the seat on the flight and he wants to cancel it.
The system askes A to enter his passport number to cancel it from the system without any
problems and in an efficient way. After “A” entered his passport number the system pop in your
record has been deleted from the system.
If “A” entered the wrong passport number by mistake the system pop in hey passport
number is wrong, please check your passport number and enter it again.
The interface is displaying all the user’s records that now you have two seats Ahmed with
his details and “A” with his details as well. There’s a line between the users to make it
clear to read and do not misunderstand it.
display function
After “A” cancel his seat from the system, the interface is showing that only One person
is in the system and A’s seat already deleted.
after entered 4 which is exit function, it is storing all the records into file with all the passenger’s
details in Airline record.
The interface is showing the record in notepad which is the storing part and it is displaying ahmed
and his details after “A” cancel his record.
Conclusion
The Airline reservation system is designed for users to reserve a seat, cancel,
display seats and exit the system. A formula is included in the function to calculate the
seats are reserved. Pseudocode is written for some important codes. A few flow charts are
also created for explaining the process of the Airline reservation system.
From this Project, I have learned to implement a few C concepts in future projects
such as functions, switch statements and do…while statements, arrays, pointers, and
structures in the program. I have also learned to create flow charts for explaining the
program.
~THANK YOU!