PLEAS WRITE THIS IN C The Federation has asked you to develop a program to keep
ID: 643565 • Letter: P
Question
PLEAS WRITE THIS IN C
The Federation has asked you to develop a program to keep track of its
officers. A sample of the kind of information for each officer is
shown below.
Name: Mr. James Tiberius Kirk
Date of Birth: March 22, 2233
Address: 23 Falling Rock,
Riverside, Iowa 52327-0021
Planet Earth
Rank: Captain
Ship: USS Enterprise
Nickname: Jim
Favorite Saying: "Bones???"
Starting Stardate: 41153.7
Martial Status: Single
Starfleet Graduation Date: June 23, 2212
Name: Mr. Leonard A. McCoy Jr.
Date of Birth: 7/8/2227
Address: 8745 South Road
Jackson, Mississippi 39201-0001
Planet Earth
Rank: Chief Medical Officer
Ship: USS Enterprise
Nickname: Bones
Favorite Saying: "He's dead Jim."
Starting Stardate: 41151.8
Marital Status: Divorced
Starfleet Graduation Date: June 21, 2210
Provide the code need to DECLARE an array of structures given the above
information. Don't write a program and don't worry about initializing
the structure based on the information above.
Be careful on how you declare the members of a structure. Grading
will be based on how the flexibility of your design (i.e., define many structures and have structures within structures if necessary).
Note: Don't go overboard such as having a structure with only one member
just to create many structures.
Explanation / Answer
NOTE
Declare first the struct string_data and struct int_data before declaring struct officer
else c compiler will show error
struct string_data{
char type[35]; //maximum needed is size of Starfleet Graduation Date: <35
char data[100];//assuming maximum data can be 100,
}
struct int_data{
char type[30];
float data;//int is not possible ,as in example it has decimal places
}//needed only for Starting Stardate:
typedef struct string_data DString;
//its a keyword in c so that we can write the typedef name " DString" instead of "struct string_data"
typedef struct int_data IString;//same here write instead of "struct int_data"
struct officer{
DString name; //same as struct string_data name
DString DOB; //DOB means date of birth
DString address; //same as struct string_data address
DString rank;
DString ship;
DString nick_name;
DString fav_saying;
DString marital_status;
DString graduation_date;
IString star_date; //same as struct int_data star_date;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.