Use the code below to answer the next questions. IGNORE COMPILE ERRORS. Assume t
ID: 3559721 • Letter: U
Question
Use the code below to answer the next questions. IGNORE COMPILE ERRORS. Assume the following sizes for the questions: int 1 bytes, char 1 bytes, float 4 bytes, double 8 bytes, pointers 8 bytes.
x) #include
y) struct personal_data {
z) char *fname;
a) char *lname;
b) int year_of_birth;
c) char gender;
d) double GPA;
e) } people[10], current_person, *pPtr;
f) int main (void) {
h) *pPtr = &people;
j) ============ missing code ============
k) return 0;
m) }
Explanation / Answer
1. The variables in a structure are accessed using "." dot
operator.Any manipulation on the variable is possible only by
refereing "structure_variable.variable_name".
Therefore the answer is people[0].gender='m'[b]
2.The size of a strucure variable is always the sum of the individual
sizes of the variables present in the structure.
Therefore the size of the variable current_person is (8+8+1+1+8) 26 bytes.
3.Arrays size is always product of the size of the data type and the
length of the array.
Therefore the size of the array people[] is 26*10 that is equal to 260 bytes.
4.The line "e" declares and allocates memory to the variables
people[10],current_person,*pPtr of type personal_data.
5.A structure variable can be instantiated directly by using the
following syntax
current_person=
{"String_name","String_name",int_value,'char_value',float_value}
Therefore the statement is True.
6.The structure variable can be accessed in two ways.The normal
variable is accessed using "dot" operator and the pointer variables
are accessed using arrow operator.
The answer is dot and arrow operator.
7.The structures are not by default pass by value. we can use any type
of pass but it is preferable to pass a structure by reference than
value.
Therefore the statement is False.
8.Structure can use pointer to pass parameters to a function.
Therefore the statement is True
9.
code to print the values of first and last name of the current_person
Printf("%s",current_person.fname);
printf("%s",current_person.lname);
10.double checkIt(personal_data *pPtr);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.