C Arrays and Strings: Beginner Test
This beginner C test covers arrays and strings, the first data structures every C programmer meets. Questions check how sizeof gives the byte size of an array and its element count, why integer division drops the fraction, how an array passed to a function decays to a pointer, the difference between strlen and sizeof on a char array, why == compares addresses while strcmp compares characters, the terminating null character and what happens when a string literal fills an array exactly, which array indices are valid and why C does not check them, char values as ASCII codes, why arrays cannot be assigned, and how partial initializer lists zero the remaining elements. Every code question is a complete program you can compile with gcc in the C/C++ sandbox and run to check your answer. The test has 10 multiple-choice questions, and each answer comes with an explanation of the mechanism behind it.
Comentarii