144k views
5 votes
(5 pts) Write the type declaration for a struct DataType named Appointment containing the following members: - a string variable representing the name of the appointment - A Date variable indicating the date of the appointment where Date is a structure already defined - A Time variable indicating the time of the appointment where Time is a structure already defined

User Hanz
by
7.2k points

1 Answer

5 votes

Answer:

  1. struct Appointment {
  2. char name[20];
  3. struct Date d;
  4. struct Time t;
  5. };
  6. struct Date{
  7. int year;
  8. int month;
  9. int day;
  10. };
  11. struct Time{
  12. int hour;
  13. int minutes;
  14. int seconds;
  15. };

Step-by-step explanation:

To create a struct data type, let use the keyword "struct" and followed with the variable name, Appointment (Line 1).

Next create the string member, name (Line 2).

Next we need to include two other struct data types (Date and Time) as part of the member of the existing struct. To do so, we can try to define the struct for Date (Line 8 - 12) and Time (Line 14 - 18) separately.

At last, we include the struct Date & Time into the Appointment struct (Line 3-4)

User Ganesh Aher
by
7.1k points