C Structures/Arrays Using your knowledge gained in the C language, develop a str
ID: 3911210 • Letter: C
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 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 numbers)
-double (floating point with many decimal places)
-char (single character)
-char name[x] (character string: x is the size, name is variable, what is a worst case size to handle your information on anyone?)
-struct name (a structure with one ore more members)
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.
Explanation / Answer
Please find the C structures below:-
#include<stdio.h>
typedef struct NameDetails{
char firstName[50];
char middleName[50];
char lastName[50];
};
typedef struct ContactDetails{
int phoneNo;
int mobileNo;
int faxNo;
char emailId[50];
};
typedef struct DateDetails{
int dateOfIssue;
int monthOfIssue;
int yearOfissue;
int dateOfExpiry;
int monthOfExpiry;
int yearOfExpiry;
};
typedef struct PassportDetails{
char passportNo[20];
char type[1];
char country[50];
char nationality[20];
char dateOfBirth[10];
char sex[1];
char address[100];
char bloodGroup[3];
struct NameDetails nameDet;
struct ContactDetails contactDet;
struct DateDetails dateDet;
};
typedef struct LicenseDetails{
char vehicleOwner[100];
char status[10];
char RTO[50];
char licensePlate[15];
int driverHeight;
float driverWeight;
char eyeColor[10];
char hairColor[10];
char bloodGroup[3];
char SSN[10];
char language[5][20];
int transportType;
char COVCategory[10];
char vehicleClass[10];
char COVIssueDate[10];
struct DateDetails licenseDateDet;
struct PassportDetails passportDet; // each driver has a Passport which contains the driver's Passport information
};
int main(){
system("cls");
struct LicenseDetails licenseDet[10]; // create an array of 10 Drivers for whom we want to store details
system("PAUSE");
return 0;
}
Please let me know in case of any clarifications required. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.