1. int count = 0; while ( *p != 0 ) { -------- if ( *p % 2 == 1 ) { -------- count = count + 1; } p = p + 1; ------- ------- } NOTE: you use "*p" whenever you want to work with an actual int value; you use "p" whenever you want to work with a value's address. 2. int * smaller(int * a, int * b) { if ( *a < *b ) return a; else return b; } NOTE: it wasn't specified what you should have done if the two values were the same; I accepted pretty much anything in that case. 3. double * p = (double *) malloc (sizeof(double)); *p = 16.5; 4. if (p == NULL) printf("Out of memory.\n"); NOTE: be careful not to introduce extra code that wasn't asked for! For this question, I saw many cases of the following: - declaring and allocating "p". - doing something if p != NULL. - returning some value (there isn't even a function here ... how can you know what needs to be returned??!!). NOTE: I was sticky on using == ... it cost you a point if you only used one equals symbol. It is *very* important to use the right operator (assignment vs. comparison) in C, as often they both can produce proper syntax. However, using the wrong one usually creates a very difficult bug to find. 5. Offset = 18 ------ NOTE: the 1-D offset is always calculated as "i * NCOLS + j". In this case, i = 4, j = 2 and NCOLS = 4. The offset is therefore 4 * 4 + 2 = 18. NOTE: a common mistake is to calculate the offset of the wrong element. Row index 4 is the FIFTH row, and column index 2 is the THIRD column. NOTE: another common mistake is to multiply the row index by the number of ROWS, instead of the number of COLUMNS. Remember, the multiplication is to *skip* a certain number of rows (in this case 4), and each row has NCOLS columns; therefore you need to jump i * NCOLS element to get to the (i+1)st row. From there you just jump to the (j+1)st column by adding another j elements to your offset. 6. (c) int * m = (int *) malloc (15*32*sizeof(int)); NOTE: (a) is wrong because 1/ malloc() only has one parameter (the total number of bytes needed), and 2/ you need an int pointer, not a 2-D array as the variable. NOTE: (b) is wrong because it is not dynamic allocation -- it's actually totally correct for static allocation, but the question asked specifically for dynamic allocation. NOTE: (d) is wrong because malloc() only has one parameter. In fact, this is the right way to allocate with "calloc()", which does the same thing as malloc() only goes through the allocated space afterwards and zeros all the elements. But malloc() just takes the total number of bytes needed.