These are sample questions that are very similar to the ones I will ask on the midterm.
void f(int a, int b)
{
printf("%d %d\n", a, b);
}
void main(void)
{
int i = 5;
f(++i, ++i);
}
int numbs[10];which of the following are equivalent, and why?
int *ptr = numbs;
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);
}
You can also obtain a PDF version of this. | Version of October 21, 2015 at 5:20PM |