These are sample questions that are very similar to the ones I will ask on the midterm. The actual midterm will be longer.
void f(int a, int b) { printf("%d %d\n", a, b); }void main(void) { int i = 5; f(i++, i++); }
int numbs[10]; int *ptr = numbs;which of the following are equivalent, and why?
for(x = i = 0; i <= 100; i += 2, x += i);
x = i = 0; while(i++ <= 100) x += ++i;
for(x = i = 0; i <= 100; i++){ if (!(i % 2)) continue; x = x + i; }
char *x(char *s, char c) { char *r = NULL;do{ while(*s && *s != c) s++; if (*s) r = s; } while(*s++); return(r); }
void a_again(int acount) { ++acount; }int main(void) { int c; int counter = 0;
while((c = getchar()) != EOF) if (c == 'a'|| c == 'A') a_again(counter);
printf("%d\n", counter); return(0); }
|
ECS 36A, Programming & Problem Solving Version of April 22, 2024 at 4:11PM
|
You can also obtain a PDF version of this. |