C++ Program to Display Customer Details in Hotel Using Structure

This program will store the records in a structure 'hotel' as customer name, address, period of stay, type of room allotted & room charges.



Source Code
#include<iostream>
using namespace std;

struct hotel
{
    char customer_name[20];
    char address[20];
    int period_of_stay;
    char types_of_room[10];
    int room_charges;
} h[3];

int main()
{
    int i;
    for(i=0;i<3;i++)
    {
        cout<<"Enter customer name: ";
        cin>> h[i].customer_name;
        cout<<"Enter address: ";
        cin>> h[i].address;
        cout<<"Enter period of stay: ";
        cin>> h[i].period_of_stay;
        cout<<"Enter types of room: ";
        cin>> h[i].types_of_room;
        cout<<"Enter room charges: ";
        cin>> h[i].room_charges;
    }
    for(i=0;i<3;i++)
    {
        cout<<"\n Customer name is " << h[i].customer_name;
        cout<<"\n Address = " << h[i].address;
        cout<<"\n Period of stay = " << h[i].period_of_stay;
        cout<<"\n Types of stay = " << h[i].types_of_room;
        cout<<"\n Room charges = " << h[i].room_charges;
    }
    return 0;
}
Output
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