/* I want to write a program that returns the last element of a linked list of elements. For example, last(2,4,6,8) should return 8. But I'm going to make an intensional mistake: */ #include #include struct cell { int car; struct cell * cdr; }; struct cell* cons(int head, struct cell* tail) { struct cell* A = (struct cell*)malloc(sizeof(struct cell)); A->car = head; A->cdr = tail; return A; } int lastval(struct cell * M) // written with a mistake: { while (M->cdr != NULL) M = M->cdr; return (int)M; // what should this really be? (int)M? } int main() { struct cell* M = cons(2,cons(4,cons(6,NULL))); printf("%d\n", lastval(M) + 4); // give me 10 PLEASE! }