QUESTIONS AND SOLUTIONS RATED A+
✔✔typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days;
days x = Mon, y = Sat;
while (x != y) { x++; }
y++;
printf("x = %d, y = %d", x, y);
1. What value will be printed for variable x? [x].
2. What value will be printed for variable y? [y] - ✔✔x = 6, y = 7
✔✔Consider the following snippet of code in a 32-bit computer.
struct contact {
char name[30];
int phone;
char email[30];
} x;
What is the size of variable x in bytes? - ✔✔68
✔✔When is padding required for a structure type variable? - ✔✔When the structure
contains a word-type variable, such as integer, float, and pointer, and the total number
of bytes is not a multiple of four.
✔✔The size (number of bytes) of a structure-type variable can be changed by the
following factors. Select all that apply. - ✔✔changing the computer from a 32-bit to a 64-
bit processor.
changing the orders of the members in the structure.
adding a member into the structure.
✔✔What parameters are required when performing file operations fread and fwrite? -
✔✔Destination
Item Size
Number of Items
Source
✔✔When will the buffer be created? - ✔✔When the file operation fopen is performed.
✔✔The reason that we need to call fflush() or cin.ignore() is because the previous -
✔✔input leaves a character in the file buffer.
, ✔✔Assume that the search function of a linked list is specified by
struct Terminal* search();
What values can the search function return? Select all correct answers. - ✔✔The
address of a teminal node
0
✔✔Assume pointer variable p points to node x, and node x's next pointer points to node
y. What does free(p) opeartion mean? - ✔✔return the memory held by x to the free
memory pool.
✔✔Assume this is a 32-bit environment, what is the size of x? (HINT: Don't forget about
padding.)
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} x; - ✔✔68 bytes
✔✔Given the information below, how will you access the name for a terminal node
pointed to by x?
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} *x; - ✔✔x->name;
✔✔Given the information below, which of the following snippet of codes will print every
terminal in the linked-list without any side-effects of changing the state. Assume head is
the only reference to the linked-list and there are more than one terminal in the list.
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} *head, *x; - ✔✔x = head;
while(x != NULL) {
printf("%s - %s", x->name, x->location);
x = x->next;