Which structure operations are permitted?

A sensor logger uses the following declarations inside a C17 function. Consider each candidate statement independently, immediately after these declarations.


C
struct Reading {
    int code;
    int samples[2];
};

struct Backup {
    int code;
    int samples[2];
};

struct Reading a = { 21, { 6, 8 } };
struct Reading b = { 34, { 2, 5 } };
struct Backup c = { 0, { 0, 0 } };


The candidates are numbered only to identify their table rows.


C
/* Statement 1 */ b = a;
/* Statement 2 */ b.samples = a.samples;
/* Statement 3 */ b.samples[1] = a.samples[0];
/* Statement 4 */ b == a;
/* Statement 5 */ c = a;


Enter valid if a statement satisfies the C17 language constraints, or invalid otherwise. Assume no casts or compiler extensions.

CandidateClassification
Statement 1
Statement 2
Statement 3
Statement 4
Statement 5

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Structure Types Questions: