Railway reservation program in C

Hello Dear, Today we learn about Railway ticket Booking Program in C, with help of the Conditional statement If-else and Switch statement (Break & Case).  I hope in this program you will learn something new. Lets start… Railway reservation program in C language for ticket booking.

C program for ticket booking

#include<stdio.h>
#include<stdlib.h>
int main()
{
int class1;
int b;
int a;
int input;
char ch;

printf(“\n\t\t\t————–Welcome to the Ranchi Railway station————-\n”);
printf(“\nPress 1 for First Class Seat Reservation!”);
printf(“\n\nPress 2 for Economy Class Seat Reservation!\n “);
scanf(“%d”, &class1);

switch(class1)
{
case 1:
{
printf(“\n Enter your seat Number in First class:-“);
scanf(“%d”,&a);
if (a < 100)
{
printf(“\n\t\t\t\t\t\t\t\t————–Your Ticketing Details—————-\n”);
printf(“Your Class: First Class”,class1);
printf(“\nYour Seat Number:- %d \n\n“, a);
}
else
{
printf(“\n seats full do you wanna resreved in Economy?:-“);
scanf(” %c“,&ch);
if(ch ==’y’||ch == ‘Y’)

{
printf(“\nYour ticket has been booked in Economy Class”);
printf(“\nYour Seat Number:- %d \n\n”,a);
}
break;
}
case 2:
{
printf(“\n Enter your seat Number in Economy class:”);
scanf(“%d“,&b);
if (b >= 101 || b < 200)
{
printf(“\n\t\t\t\t\t\t\t\t————–Your Ticketing Details—————-\n“);
printf(“Your Class: economy Class”,class1);
printf(“\nYour Seat Number:- %d“, b);
}
else
{
printf(“\n Sorry seats full do you wanna resreved in First class(Y or N) ?:-“);
scanf(“ %c“,&ch);
if(ch ==’y’||ch==’y’)

{
printf(“\nYour ticket has been booked in Economy Class”);
printf(“\nYour Seat Number:- %d“,a);
}
break;

default:
printf(“\n Sorry There is an Error ! Please choose given Option \n\n\t\t\t Thank You “);
break;

}
}

return 0;
}
}
}

C program for the ticket reservation system

C Program to Draw a Rainbow (click)

1st Run

Here you have to give Two Options where you can choose one of them. Let If you choose 1st Option then you get Output like ( Press 1 for first-class and Press 2 for Economy Class)

Railway reservation program in C
Railway reservation program in C
Railway reservation program in C
Railway reservation program in C

 

Railway reservation program in C
Railway reservation program in C

2nd Run

Railway reservation program in C
Railway reservation program in C

 

Railway reservation program in C
Railway reservation program in C

 

Railway reservation program in C
Railway reservation program in C

3rd Run

If you choose the Right option then it’ll proceed else, It tells you { Sorry There is an Error! Please choose the given Option Thank You}

Railway reservation program in C
Railway reservation program in C

 

Railway reservation system in C

In case if You Enter a higher Value of Seat then it gives you a Message Like

Seats full do you wanna reserved in Economy?:-” (Here you Need Press ‘Y’ for Yes and ‘N’ for No) }

Railway reservation program in C language

END

C program to draw a square using graphics (clickHere)

Note:- Maybe sometime above code doesn’t get user-friendly output, in codeblock ‘or’ any other EDITOR, All of C & C++ program tested in DOS compiler Turbo C.

Also Read

Types of functions in C    Read Here

I hope you will understand better if you study at M.U, in the exam of M.U you know how important this “Railway reservation program in C

. So please don’t forget to give your valuable feedback. Go in the comment section and Give us some feedback about it. Railway reservation program in C  or My website.

Our team check your every Comment per day Because your one feedback helps us in growing Thesmolt

I request you if you have any doubt or question regarding our site, then please don’t hesitate. We always waiting for your Suggestion.

Note:- If you want to Download This article’s in PDF form, then simply go (Top or Bottom of) Right corner and click on the PRINT icon, and it’s saved as a PDF of  Railway reservation program in C

For further questions, you can contact us Via mail [email protected]  otherwise, Our Help Page and Contact us Page, which is included below. I hope I’ll able to say all the possible ways to reach us. Or Download My Android Application Below Download Button.

thesmolt App

Leave a Reply

x