5.0010. Given the following sections of C
code:
struct emp
{ char lname[7],
dept[5];
short age, class;
float salary;
};
void main()
{
struct emp employee[6];
printf (“%lu\n”, &employee[2].class); // The output
would be 6420
a. What would be printed out by the command:
printf(“%lu”,
employee);
Since the address of &employee[2].age
is 6420
then &employee[2]
is: 6420 – 2 – 5 – 7 = 6406
If the address of &employee[2]
is 6406 and each record requires:
7 + 5 + 2 + 2 + 4 = 20 bytes
Then the address of employee (== &employee[0])
= 6408 - 2 * 20 = 6406 – 40 = 6366