Struct User Defined Data Type

This is an example of creating a simple user-defined data type/class using struct

#include <cstdio>

struct Apartment {
    char apartment_name[256];
    int apartment_number;
    int square_feet;
    int bedrooms;
    float bathrooms;
    bool appliances_included;
};


int main() {

    //  Initializing All field set 
    Apartment TheTerrace{ "Terrace", 324, 1000, 2, 2.5, false};
    printf("The %s apartment %d has %d square_feet, %d bedrooms, and %f bathrooms\n", TheTerrace.apartment_name, 
            TheTerrace.apartment_number, TheTerrace.square_feet, TheTerrace.bedrooms, TheTerrace.bathrooms);

    //  Initialized field set differently.
    Apartment CWSApartments{"CWSApartments"};
    CWSApartments.apartment_number = 26;
    CWSApartments.square_feet = 567;
    CWSApartments.bedrooms = 1;
    CWSApartments.bathrooms = 1.0;
    CWSApartments.appliances_included = true;
    printf("The %s apartment %d has %d square_feet, %d bedrooms, and %f bathrooms\n", CWSApartments.apartment_name, 
           CWSApartments.apartment_number, CWSApartments.square_feet, CWSApartments.bedrooms, CWSApartments.bathrooms);
}

Compiling and running the code.

$ g++ struct.cpp -std=c++17 -o struct
$ ./struct 
The Terrace apartment 324 has 1000 square_feet, 2 bedrooms, and 2.500000 bathrooms
The CWSApartments apartment 26 has 567 square_feet, 1 bedrooms, and 1.000000 bathrooms