© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

CPP Program For Railway Reservation
#include #include #include struct rail { int seatNo; int isEmpty; }seat[67]; void reserve(int n); int arrRowState[15]; void main() { for(int i = 0 ; i <67 ; i++) { seat[i].seatNo=(i+1); seat[i].isEmpty=1; } for(i=0 ; i<13 ; i++) arrRowState[i]=5; arrRowState[13]=2; arrRowState[14]=67; char res='y'; do { int n; clrscr(); cout<<"Enter d no of seats u want to reserve : "<>n; reserve(n); cout<<"\nDo u want to reserve more seats?(press y to continue)"<arrRowState[14]) { cout<<"Too large group to accomodate"<= n) { flag=1; // cout<<"Following Seats Alloted"; seatbook=(((i)*5)+(6-arrRowState[i])); for(int j = 0 ; j < n ; j++) { cout<<" "< max) { max=arrRowState[j]; rowNo=j; } } if(n>max) { n=n-max; seatbook=(((rowNo)*5)+(6-arrRowState[rowNo])); arrRowState[rowNo]=arrRowState[rowNo]-max; for( int j = 0 ; j

Sample Output :

Enter d no of seats u want to reserve :
5

  1. 2  3  4  5

Do u want to reserve more seats?(press y to continue)
Y

 

Enter d no of seats u want to reserve :
7

  1. 7  8  9  10  11  12

Do u want to reserve more seats?(press y to continue)
Y

Enter d no of seats u want to reserve :
9

  1. 17  18  19  20  21  22  23  24

Do u want to reserve more seats?(press y to continue)
N

 
SLogix Student Projects


⇓Student Projects⇓
⇑Student Projects⇑
bottom