Question: C Structures / Arrays Using your knowledge gained in the C language, develop a structure declaration (see template below) that will model the attributes you
C Structures / Arrays
Using your knowledge gained in the C language, develop a structure declaration (see template below) that will model the attributes you see on a US Passport. You do not have to populate it with actual information, just provide a set of structures that could be use to model and capture the driver license data. Think of what type each member of the structure should be, for example
- int (whole numbers)
- float (floating point)
- double (floating point with many decimal places)
- char (single character)
- char name[x] (character string, x is the size, name is variable)
- struct name (a structure with one ore more number)
You will probably note that many of your members in the struct passport item will probably be structures themselves. Look at each item on your license and think if there is a group of data that belongs together. For example, when I see DOB on my passport, its contains a date value that has month, day, and year. You will also see other things, for example, passport (card) number, that probably make more sense just being a simple member that is itself not a structure type.
/* add structures */
#define SIZE 5
/* add supporting structures */
struct date
{ int month; int day; int year; };
/* add other supporting structures */
/* the actual passport structure that will contain all needed members */ struct passport
{
char number [25]; /* alpha numeric passport number - combo of letters and numbers, 25 should be enough */ struct date birthDate; /* the date the traveler was born, note that its a structure member within the passport structure */
/* add other members - some will be structure types, */
/* others will be one of the types mentioned above */
};
/* declare an array of SIZE number of travelers */ struct passport travelers [SIZE];
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
