0% found this document useful (0 votes)
4 views

CSE CODE

The document outlines a C program for managing hotel accommodations, allowing users to add customer bookings and print existing bookings. It defines a structure for customer data, including name, check-in date, number of nights, and room number. The program runs in a loop, providing options to add customers, display bookings, or exit the application.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CSE CODE

The document outlines a C program for managing hotel accommodations, allowing users to add customer bookings and print existing bookings. It defines a structure for customer data, including name, check-in date, number of nights, and room number. The program runs in a loop, providing options to add customers, display bookings, or exit the application.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

HOTEL ACCOMMODATION

#include <stdio.h>

#include <string.h>

#define MAX_CUSTOMERS 100

struct Customer

char name[50];

char checkIn[11];

int nights;

int roomNum;

};

struct Customer customers[MAX_CUSTOMERS];

int numCustomers = 0;

void addCustomer()

if (numCustomers >= MAX_CUSTOMERS)

printf("Error: No more room for new customers.\n");

return;

printf("Enter customer name: ");

scanf("%s", customers[numCustomers].name);
printf("Enter check-in date (MM/DD/YYYY): ");

scanf("%s", customers[numCustomers].checkIn);

printf("Enter number of nights: ");

scanf("%d", &customers[numCustomers].nights);

printf("Enter room number: ");

scanf("%d", &customers[numCustomers].roomNum);

numCustomers++;

void printBookings()

if (numCustomers == 0)

printf("No bookings to display.\n");

return;

printf("List of Bookings:\n");

for (int i = 0; i < numCustomers; i++)

printf("%s: Room %d, %d nights, starting on %s\n", customers[i].name, customers[i].roomNum,


customers[i].nights, customers[i].checkIn);

int main()

int choice;
while (1)

printf("1. Add customer\n");

printf("2. Print bookings\n");

printf("3. Exit\n");

printf("Enter your choice: ");

scanf("%d", &choice);

switch (choice)

case 1:

addCustomer();

break;

case 2:

printBookings();

break;

case 3:

return 0;

default:

printf("Invalid choice.\n");

break;

return 0;

}
OUTPUT

1. Add customer

2. Print bookings

3. Exit

Enter your choice:

You might also like