UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

5.7.4.  Self-assessment questions

  1. Consider the following code fragment:

    struct data
    {
        struct data *s;
    } a, b, c;

    Which three lines of code are required to create a circular data structure (a.s points to b, b.s points to c, y c.s points to a)?

    • a.s = b; b.s = c; c.s = a;

    • &a.s = b; &b.s = c; &c.s = a;

    • a.s = *b; b.s = *c; c.s = *a;

    • a.s = &b; b.s = &c; c.s = &a;

  2. Consider the following code fragment:

    struct data
    {
        int i;
        int j;
    } a;
    struct data *b = &a;

    How can you calculate the addition of fields i y j of structure a using only variable b?

    • b->i + b->j

    • *b->i + *b->j

    • b.i + b.j

    • It cannot be computed.