Answer to q6, midterm E02 practice questions


  1. (25 pts) Together with this exam, there is a program (on a separate handout).

    Assuming each of the expressions below appeared in this program, indicate the type they would have, or write error if the expression is not valid, e.g.



    The first few are done for you as an example.

    Hints--for full credit:

    Expression Type      Expression Type
    a int   f->radius double    
    &a int *   f->center.x double
    *a error   f->center->y error (f->center is not a pointer)
    *b int   &g struct Point *
    e struct Circle   *h struct Point
    b int *   &(h->x) double *
    & b int ** d *(h.y) error (h.y is already an error because h is not a struct)
    c double   i.m int
    *c error (c is not a pointer)   j.d error (j is not a struct)
    d double *   i->y error (i is not a pointer)
    &d double **   j->m int
    *e error (e is not a pointer) er (*j).m int (means same thing as j->m)
    e.x error (circle has no member named x)   argc int
    e.radius double   argv[0] char *
    f.y error (f is not a struct)   argv[0][0] char