This program will store the records in a structure 'hotel' as customer name, address, period of stay, type of room allotted & room charges.
#include<stdio.h>
#include<conio.h>
struct hotel
{
char customer_name[20];
char address[20];
int period_of_stay;
char types_of_room[10];
int room_charges;
}h[3];
void main()
{
int i;
//clrscr();
for(i=0;i<3;i++)
{
printf("Enter customer name: ");
scanf("%s", &h[i].customer_name);
printf("Enter address: ");
scanf("%s", &h[i].address);
printf("Enter period of stay: ");
scanf("%d", &h[i].period_of_stay);
printf("Enter types of room: ");
scanf("%s", &h[i].types_of_room);
printf("Enter room charges: ");
scanf("%d", &h[i].room_charges);
}
for(i=0;i<3;i++)
{
printf("\n Customer name is %s", h[i].customer_name);
printf("\n Address = %s", h[i].address);
printf("\n Period of stay = %d", h[i].period_of_stay);
printf("\n Types of stay = %s", h[i].types_of_room);
printf("\n Room charges = %d", h[i].room_charges);
}
getch();
}
Enter customer name: Soham
Enter address: Pune
Enter period of stay: 3
Enter types of room: AC
Enter room charges: 600
Enter customer name: Dinesh
Enter address: Mumbai
Enter period of stay: 2
Enter types of room: Non-AC
Enter room charges: 300
Enter customer name: Kamlesh
Enter address: Pune
Enter period of stay: 4
Enter types of room: AC
Enter room charges: 600
Customer name is Soham
Address = Pune
Period of stay = 3
Types of stay = AC
Room charges = 600
Customer name is Dinesh
Address = Mumbai
Period of stay = 2
Types of stay = Non-AC
Room charges = 300
Customer name is Kamlesh
Address = Pune
Period of stay = 4
Types of stay = AC
Room charges = 600