struct personalInfo
{
char name[ 50 ] ;
char dateOfBirth[ 50 ] ;
char address[ 150 ] ;
char martialStatus[ 50 ] ;
char nickname[ 50 ] ;
char favoriteSaying[ 100 ] ;
} ;
struct employDates{
char lastPromotionDate[ 50 ] ;
float startingStarDate;
char starfleetGradDate[ 50 ] ;
} ;
struct otherEmployInfo{
char rank[ 50 ] ;
char ship[ 50 ] ;
char starfleetID[ 50 ] ;
float hourlyPay;
} ;
struct officer
{
struct personalInfo infoPersonal;
struct employDates infoDates;
struct otherEmployInfo infoOtherEmploy;
} ;
#include <stdio.h>
int main( void ) {
//Declare an array of structures
struct officer arrayOfficers[ 2 ] = {
{ { "Mr. James Tiberius Kirk" , "March 22, 2233" , "23 Falling Rock, Riverside, Iowa 52327-0021 Planet Earth" , " Single" , " Jim" , "Bones???" } ,
{ "April 12, 2224" , 41153.7 , "June 23, 2212" } ,
{ "Captain" , "USS Enterprise" , "02341232" , 456.78 } } ,
{ { "Mr. Leonard A. McCoy Jr." , "7/8/2227" , "8745 South Road Jackson, Mississippi 09201-0001 Planet Earth" , "Divorced" , "Bones" , "He's dead Jim." } ,
{ "June 24, 2216" , 41151.8 , "June 21,2210" } ,
{ "Chief Medical Officer" , "USS Enterprise" , "00034212" , 234.56 } }
} ; // Given details for two officers for this question so I am declaring an array of size 2 in this case
// Print the initialized structure
for ( int i = 0 ; i < 2 ; i++ ) {
printf ( "Name: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
name ) ; printf ( "Date of Birth: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
dateOfBirth ) ; printf ( "Address: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
address ) ; printf ( "Martial Status: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
martialStatus ) ; printf ( "Nickname: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
nickname ) ; printf ( "Favorite Saying: %s\n " , arrayOfficers
[ i
] .
infoPersonal .
favoriteSaying ) ; printf ( "Last Promotion Date: %s\n " , arrayOfficers
[ i
] .
infoDates .
lastPromotionDate ) ; printf ( "Starting Star Date: %0.1f\n " , arrayOfficers
[ i
] .
infoDates .
startingStarDate ) ; printf ( "Star Fleet Grad Date: %s\n " , arrayOfficers
[ i
] .
infoDates .
starfleetGradDate ) ; printf ( "Rank: %s\n " , arrayOfficers
[ i
] .
infoOtherEmploy .
rank ) ; printf ( "Ship: %s\n " , arrayOfficers
[ i
] .
infoOtherEmploy .
ship ) ; printf ( "Starfleet ID: %s\n " , arrayOfficers
[ i
] .
infoOtherEmploy .
starfleetID ) ; printf ( "Starfleet Graduation Date: %0.2f\n " , arrayOfficers
[ i
] .
infoOtherEmploy .
hourlyPay ) ; printf ( "---------------------------" ) ; }
return 0 ;
}
c3RydWN0IHBlcnNvbmFsSW5mbwp7CiAgICBjaGFyIG5hbWVbNTBdOwogICAgY2hhciBkYXRlT2ZCaXJ0aFs1MF07CiAgICBjaGFyIGFkZHJlc3NbMTUwXTsKICAgIGNoYXIgbWFydGlhbFN0YXR1c1s1MF07CiAgICBjaGFyIG5pY2tuYW1lWzUwXTsKICAgIGNoYXIgZmF2b3JpdGVTYXlpbmdbMTAwXTsKCn07CgpzdHJ1Y3QgZW1wbG95RGF0ZXN7CiAgICBjaGFyIGxhc3RQcm9tb3Rpb25EYXRlWzUwXTsKICAgIGZsb2F0IHN0YXJ0aW5nU3RhckRhdGU7CiAgICBjaGFyIHN0YXJmbGVldEdyYWREYXRlWzUwXTsKCn07CgpzdHJ1Y3Qgb3RoZXJFbXBsb3lJbmZvewogICAgY2hhciByYW5rWzUwXTsKICAgIGNoYXIgc2hpcFs1MF07CiAgICBjaGFyIHN0YXJmbGVldElEWzUwXTsKICAgIGZsb2F0IGhvdXJseVBheTsKCn07CgpzdHJ1Y3Qgb2ZmaWNlcgp7CiAgICBzdHJ1Y3QgcGVyc29uYWxJbmZvIGluZm9QZXJzb25hbDsKICAgIHN0cnVjdCBlbXBsb3lEYXRlcyBpbmZvRGF0ZXM7CiAgICBzdHJ1Y3Qg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