0% found this document useful (0 votes)
25 views3 pages

Project 3

Uploaded by

Ayush Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Project 3

Uploaded by

Ayush Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

h>
#include<stdlib.h>
#include<string.h>

struct Train
{
char train_name[100];
int train_number;
char departure_station[50];
char arrival_station[50];
int total_seats;
int booked_seats;
};

struct Passenger
{
char name[50];
int passenger_id;
int booked_train_number;
int seat_number;
};

int new_train (struct Train *tr) {


printf("Enter train name:");
scanf("%s", tr->train_name);
printf("Enter train number:");
scanf("%d", &tr->train_number);
printf("Enter departure station:");
scanf("%s", tr->departure_station);
printf("Enter arrival station:");
scanf("%s", tr->arrival_station);
printf("Enter total seats:");
scanf("%d", &tr->total_seats);

printf("\nTrain added Successfully!");


return 0;
}

int new_passenger (struct Passenger *pr) {

printf ("Enter passenger name:");


scanf("%s", pr->name);
printf("Enter passenger id:");
scanf("%d", &pr->passenger_id);
return 0;
}

int book_ticket(struct Passenger *tk) {


printf("Enter passenger ID:");
scanf("%d", &tk->passenger_id);
printf ("Enter train number to book:");
scanf("%d", &tk->booked_train_number);
printf("\nTicket booked successfully!");
}

int main() {
int choice;
printf("Railway Managment System\n");
printf ("1.Add New Train\n");
printf ("2.Register New Passenger\n");
printf ("3.Book a Ticket\n");
printf ("4.Cancel a Ticket\n");
printf ("5.Search for Trains\n");
printf ("6.Display Train Schedule\n");
printf ("7.Save Data to File\n");
printf ("8.Load Data from File\n");
printf ("9.View Booking Statistics\n");
printf ("10.Exit\n");
scanf ("%d", &choice);

int i = 0, j = 0, n = 0;
struct Train trains[100];
struct Passenger passengers[1000];
struct Passenger tickets[10000];

switch (choice) {
case 1:
if (i<100) {
new_train (&trains[i]);
i++;
}
else
printf("Trains limit exceeded,cannot add more train");
break;

case 2:
if (j<1000) {
new_passenger(&passengers[j]);
j++;
}
else
printf("Passenger limit exceeded, cannot add more");
break;

case 3:
if (n<10000) {
book_ticket(&tickets[n]);
n++;
}
else
printf("No seats available to book");

break;

case 4:

break;

case 5:

break;

case 6:

break;
case 7:

break;

case 8:

break;

case 9:

break;

case 10:

break;

default:
printf("Invalid choice. Please try again.\n");

}
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy