└── MOVIE_TICKET_BOOKING_SYSTEM.c /MOVIE_TICKET_BOOKING_SYSTEM.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Movie { 5 | char title[50]; 6 | int availableSeats; 7 | float ticketPrice; 8 | }; 9 | 10 | struct Theatre { 11 | char name[50]; 12 | char location[50]; 13 | }; 14 | 15 | struct CanteenItem { 16 | char itemName[50]; 17 | float price; 18 | }; 19 | 20 | int isEqual(char str1[], char str2[]) { 21 | int i = 0; 22 | while (str1[i] != '\0' || str2[i] != '\0') { 23 | if (str1[i] != str2[i]) { 24 | return 0; 25 | } 26 | i++; 27 | } 28 | return 1; 29 | } 30 | 31 | void displayTheatresInLocation(struct Theatre theatres[], int numTheatres, char location[]) { 32 | printf("\nAvailable Theatres in %s:\n", location); 33 | for (int i = 0; i < numTheatres; i++) { 34 | if (isEqual(theatres[i].location, location)) { 35 | printf("%d. %s\n", i + 1, theatres[i].name); 36 | } 37 | } 38 | } 39 | 40 | void displayMovies(struct Movie movies[], int numMovies, int theatreIndex) { 41 | printf("\nAvailable Movies at %s:\n", movies[theatreIndex].title); 42 | for (int i = 0; i < numMovies; i++) { 43 | printf("%d. %s (Seats: %d, Price: %.2f)\n", i + 1, movies[i].title, movies[i].availableSeats, movies[i].ticketPrice); 44 | } 45 | } 46 | 47 | void displayCanteenMenu(struct CanteenItem canteenMenu[], int numItems) { 48 | printf("\nCanteen Menu:\n"); 49 | for (int i = 0; i < numItems; i++) { 50 | printf("%d. %s (Price: %.2f)\n", i + 1, canteenMenu[i].itemName, canteenMenu[i].price); 51 | } 52 | } 53 | 54 | void bookTickets(struct Movie *selectedMovie) { 55 | int numTickets; 56 | printf("\nEnter the number of tickets to book: "); 57 | scanf("%d", &numTickets); 58 | 59 | if (numTickets > 0 && numTickets <= selectedMovie->availableSeats) { 60 | printf("Total cost: %.2f\n", numTickets * selectedMovie->ticketPrice); 61 | selectedMovie->availableSeats -= numTickets; 62 | printf("Tickets booked successfully!\n"); 63 | } else { 64 | printf("Invalid number of tickets or not enough seats available.\n"); 65 | } 66 | } 67 | 68 | void orderFood(struct Movie *selectedMovie, struct CanteenItem canteenMenu[], int numItems) { 69 | int choices[50]; 70 | int quantities[50]; 71 | int totalItems = 0; 72 | float totalPrice = 0.0; 73 | 74 | printf("\nEnter the item numbers and quantities to order (0 to finish): "); 75 | 76 | int choice; 77 | while (totalItems < 50) { 78 | scanf("%d", &choice); 79 | 80 | if (choice == 0) { 81 | break; 82 | } 83 | 84 | if (choice > 0 && choice <= numItems) { 85 | printf("Enter the quantity for %s: ", canteenMenu[choice - 1].itemName); 86 | int quantity; 87 | scanf("%d", &quantity); 88 | 89 | if (quantity > 0) { 90 | choices[totalItems] = choice; 91 | quantities[totalItems] = quantity; 92 | totalItems++; 93 | } else { 94 | printf("Invalid quantity. Try again.\n"); 95 | } 96 | } else { 97 | printf("Invalid choice. Try again.\n"); 98 | } 99 | } 100 | 101 | 102 | printf("\nItems ordered for %s:\n", selectedMovie->title); 103 | for (int i = 0; i < totalItems; i++) { 104 | printf("%d. %s (Quantity: %d)\n", i + 1, canteenMenu[choices[i] - 1].itemName, quantities[i]); 105 | totalPrice += canteenMenu[choices[i] - 1].price * quantities[i]; 106 | } 107 | 108 | printf("\nTotal cost: %.2f\n", totalPrice); 109 | printf("Food ordered successfully!\n"); 110 | } 111 | 112 | int main() { 113 | struct Theatre theatres[] = { 114 | {"Mega Star Cinemas", "Trichy"}, 115 | {"L.A.Cinemas", "Trichy"}, 116 | {"CityPlex", "Chennai"}, 117 | 118 | }; 119 | 120 | struct Movie movies[][9] = { 121 | { 122 | {"Leo", 300, 190.0}, 123 | {"Salaar", 250, 220.5}, 124 | {"K.G.F 2", 300, 250.0}, 125 | {"Parking", 100, 170.0}, 126 | {"Fast X", 180, 200.0}, 127 | {"Avengers Endgame", 300, 200.0}, 128 | {"Avatar", 250, 220.0}, 129 | {"animal", 200, 190.0}, 130 | {"jailer", 200, 220.0}, 131 | }, 132 | 133 | }; 134 | 135 | struct CanteenItem canteenMenu[] = { 136 | {"Popcorn", 40.0}, 137 | {"big popcorn", 150.0}, 138 | {"small popcorn", 90.0}, 139 | {"Coco cola", 30.0}, 140 | {"Burger", 70.0}, 141 | {"Egg puffs", 40.0}, 142 | {"Ice cream", 80.0}, 143 | {"Finger chips", 50.0}, 144 | {"panni puri", 50.0}, 145 | {"pael puri", 50.0}, 146 | {"masal puri", 50.0}, 147 | {"coffe", 60.0}, 148 | {"cold coffe", 100.0}, 149 | {"chocolate coffe", 150.0}, 150 | {"donut", 70.0}, 151 | {"tea", 50.0}, 152 | {"juice", 60.0}, 153 | {"water bottle", 30.0}, 154 | {"cool drinkes", 60.0} 155 | }; 156 | 157 | int numTheatres = sizeof(theatres) / sizeof(theatres[0]); 158 | int numItems = sizeof(canteenMenu) / sizeof(canteenMenu[0]); 159 | 160 | char location[50]; 161 | int theatreChoice, movieChoice; 162 | 163 | printf("Welcome to the Movie Ticket Booking System!\n"); 164 | 165 | printf("Enter your location: "); 166 | scanf("%s", location); 167 | 168 | do { 169 | displayTheatresInLocation(theatres, numTheatres, location); 170 | 171 | printf("\nEnter the theatre number to view movies (0 to exit): "); 172 | scanf("%d", &theatreChoice); 173 | 174 | if (theatreChoice > 0 && theatreChoice <= numTheatres) { 175 | int selectedTheatreIndex = theatreChoice - 1; 176 | struct Movie *selectedMovies = movies[selectedTheatreIndex]; 177 | 178 | do { 179 | displayMovies(selectedMovies, 9, selectedTheatreIndex); 180 | 181 | printf("\nEnter the movie number to book tickets (0 to go back): "); 182 | scanf("%d", &movieChoice); 183 | 184 | if (movieChoice > 0 && movieChoice <= 9) { 185 | struct Movie *selectedMovie = &selectedMovies[movieChoice - 1]; 186 | displayCanteenMenu(canteenMenu, numItems); 187 | 188 | int option; 189 | printf("\nSelect an option:\n1. Book Tickets\n2. Order Food\n3. Exit\n"); 190 | scanf("%d", &option); 191 | 192 | switch (option) { 193 | case 1: 194 | bookTickets(selectedMovie); 195 | break; 196 | case 2: 197 | orderFood(selectedMovie, canteenMenu, numItems); 198 | break; 199 | case 3: 200 | printf("Exiting...\n"); 201 | break; 202 | default: 203 | printf("Invalid option.\n"); 204 | } 205 | } else if (movieChoice != 0) { 206 | printf("Invalid movie choice.\n"); 207 | } 208 | 209 | } while (movieChoice != 0); 210 | } else if (theatreChoice != 0) { 211 | printf("Invalid theatre choice.\n"); 212 | } 213 | 214 | } while (theatreChoice != 0); 215 | 216 | return 0; 217 | } 218 | --------------------------------------------------------------------------------