Câu hỏi trắc nghiệm ngôn ngữ lập trình C (tiếp theo)
When applied to a variable, what does the unary "&" operator yield?
Choice 1
The variable's value
Choice 2
The variable's binary form
Choice 3
The variable's address [Ans]
Choice 4
The variable's format
Choice 5
The variable's right value
Q82:
Code:
/* sys/cdef.h */
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
/* stdio.h */
#include
div_t div __P((int, int));
The code above comes from header files for the FreeBSD implementation of the C library. What is the primary purpose of the __P() macro?
Choice 1
The __P() macro has no function, and merely obfuscates library function declarations. It should be removed from further releases of the C library.
Choice 2
The __P() macro provides forward compatibility for C++ compilers, which do not recognize Standard C prototypes.
Choice 3
Identifiers that begin with two underscores are reserved for C library implementations. It is impossible to determine the purpose of the macro from the context given.
Choice 4
The __P() macro provides backward compatibility for K&R C compilers, which do not recognize Standard C prototypes.
Choice 5
The __P() macro serves primarily to differentiate library functions from application-specific functions.
Q83:
Which one of the following is NOT a valid identifier?
Choice 1
__ident
Choice 2
auto [Ans]
Choice 3
bigNumber
Choice 4
g42277
Choice 5
peaceful_in_space
Q84:
/* Read an arbitrarily long string. */
Code:
int read_long_string (const char ** const buf) {
char * p = NULL;
const char * fwd = NULL;
size_t len = 0;
assert(buf);
do
{
p = realloc(p, len += 256);
if (!p)
return 0;
if (!fwd)
fwd = p;
else
fwd = strchr(p, '\0');
} while (fgets(fwd, 256, stdin));
*buf = p;
return 1;
}
The function read_long_string(), defined above, contains an error that may be particularly visible under heavy stress. Which one of the following describes it?
Choice 1
The write to *buf is blocked by the const qualifications applied to its type.
Choice 2
If the null pointer for char is not zero-valued on the host machine, the implicit comparisons to zero (0) may introduce undesired behavior. Moreover, even if successful, it introduces machine-dependent behavior and harms portability.
Choice 3
The symbol stdin may not be defined on some ANCI C compliant systems.
Choice 4
The else causes fwd to contain an errant address.
Choice 5
If the call to realloc() fails during any iteration but the first, all memory previously allocated by the loop is leaked.
Q85:
Code:
FILE *f = fopen( fileName, "r" );
readData( f );
if( ???? )
{
puts( "End of file was reached" );
}
Which one of the following can replace the ???? in the code above to determine if the end of a file has been reached?
Choice 1
f == EOF[Ans]
Choice 2
feof( f )
Choice 3
eof( f )
Choice 4
f == NULL
Choice 5
!f
Q86:
Global variables that are declared static are ____________.
Which one of the following correctly completes the sentence above?
Choice 1
Deprecated by Standard C
Choice 2
Internal to the current translation unit
Choice 3
Visible to all translation units
Choice 4
Read-only subsequent to initialization
Choice 5
Allocated on the heap[Ans]
Q87:
/* Read a double value from fp. */
Code:
double read_double (FILE * fp) {
double d;
assert(fp != NULL);
fscanf(fp, " %lf", d);
return d;
}
The code above contains a common error. Which one of the following describes it?
Choice 1
fscanf() will fail to match floating-point numbers not preceded by whitespace.
Choice 2
The format specifier %lf indicates that the corresponding argument should be long double rather than double.
Choice 3
The call to fscanf() requires a pointer as its last argument.
Choice 4
The format specifier %lf is recognized by fprintf() but not by fscanf().
Choice 5
d must be initialized prior to usage.
Q88:
Which one of the following is NOT a valid C identifier?
Choice 1
___S
Choice 2
1___ [Ans]
Choice 3
___1
Choice 4
___
Choice 5
S___
Q89:
According to Standard C, what is the type of an unsuffixed floating-point literal, such as 123.45?
Choice 1
long double
Choice 2
Unspecified
Choice 3
float[Ans]
Choice 4
double
Choice 5
signed float
Q90:
Which one of the following is true for identifiers that begin with an underscore?
Choice 1
They are generally treated differently by preprocessors and compilers from other identifiers.
Choice 2
They are case-insensitive.
Choice 3
They are reserved for usage by standards committees, system implementers, and compiler engineers.
Choice 4
Applications programmers are encouraged to employ them in their own code in order to mark certain symbols for internal usage. Choice 5
They are deprecated by Standard C and are permitted only for backward compatibility with older C libraries.
NGUYỄN THỊ BẢO TRANG
» Tin mới nhất:
» Các tin khác: