Multiple Choice Questions --- C Programming

Oct 28, 2013 • Don Brown

Distinguishing Novice from Competent:

How many times will “Hello World” be printed?

int x = 0;
while (x <= 10) {
 printf("Hello World!");
}

a.) 9
b.) 10
c.) 11
d.) infinite

Distinguishing Competent from Expert:

What is wrong with the following code?

foo(const char **p)
{
   // do something
} int main(int argc, char **argv)
{ 
   foo(argv); 
}

a.) Error: Argument cannot be a pointer to a pointer
b.) Warning: Argument is incompatible with prototype
c.) Error: **argv is not valid
d.) Nothing, the code will compile and run just fine