Câu hỏi trắc nghiệm ngôn ngữ lập trình C (tiếp theo)
Code:
int i = 4;
int x = 6;
double z;
z = x / i;
printf("z=%.2f\n", z);
What will print when the sample code above is executed?
Choice 1
z=0.00
Choice 2
z=1.00[Ans]
Choice 3
z=1.50
Choice 4
z=2.00
Choice 5
z=NULL
Q72:
Which one of the following variable names is NOT valid?
Choice 1
go_cart
Choice 2
go4it
Choice 3
4season[Ans]
Choice 4
run4
Choice 5
_what
Q73:
int a [8] = { 0, 1, 2, 3 };
The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements?
Choice 1
Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled.
Choice 2
The remaining elements are initialized to zero(0).[Ans]
Choice 3
It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized.
Choice 4
As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively.
Choice 5
They are left in an uninitialized state; their values cannot be relied upon.
Q74:
Which one of the following is a true statement about pointers?
Choice 1
They are always 32-bit values.
Choice 2
For efficiency, pointer values are always stored in machine registers.
Choice 3
With the exception of generic pointers, similarly typed pointers may be subtracted from each other.
Choice 4
A pointer to one type may not be cast to a pointer to any other type.
Choice 5
With the exception of generic pointers, similarly typed pointers may be added to each other.
Q75:
Which one of the following statements allocates enough space to hold an array of 10 integers that are initialized to 0?
Choice 1
int *ptr = (int *) malloc(10, sizeof(int));
Choice 2
int *ptr = (int *) calloc(10, sizeof(int));
Choice 3
int *ptr = (int *) malloc(10*sizeof(int)); [Ans]
Choice 4
int *ptr = (int *) alloc(10*sizeof(int));
Choice 5
int *ptr = (int *) calloc(10*sizeof(int));
Q76:
What are two predefined FILE pointers in C?
Choice 1
stdout and stderr
Choice 2
console and error
Choice 3
stdout and stdio
Choice 4
stdio and stderr
Choice 5
errout and conout
Q77:
Code:
u32 X (f32 f)
{
union {
f32 f;
u32 n;
} u;
u.f = f;
return u.n;
}
Given the function X(), defined above, assume that u32 is a type-definition indicative of a 32-bit unsigned integer and that f32 is a type-definition indicative of a 32-bit floating-point number.
Which one of the following describes the purpose of the function defined above?
Choice 1
X() effectively rounds f to the nearest integer value, which it returns.
Choice 2
X() effectively performs a standard typecast and converts f to a roughly equivalent integer.
Choice 3
X() preserves the bit-pattern of f, which it returns as an unsigned integer of equal size.
Choice 4
Since u.n is never initialized, X() returns an undefined value. This function is therefore a primitive pseudorandom number generator.
Choice 5
Since u.n is automatically initialized to zero (0) by the compiler, X() is an obtuse way of always obtaining a zero (0) value.
Q78:
Code:
long factorial (long x)
{
????
return x * factorial(x - 1);
}
With what do you replace the ???? to make the function shown above return the correct answer?
Choice 1
if (x == 0) return 0;
Choice 2
return 1;
Choice 3
if (x >= 2) return 2;
Choice 4
if (x == 0) return 1;
Choice 5
if (x <= 1) return 1; [Ans]{more probable}
Q79:
Code:
/* Increment each integer in the array 'p' of * size 'n'. */
void increment_ints (int p [/*n*/], int n)
{
assert(p != NULL); /* Ensure that 'p' isn't a null pointer. */
assert(n >= 0); /* Ensure that 'n' is nonnegative. */
while (n) /* Loop over 'n' elements of 'p'. */
{
*p++; /* Increment *p. */
p++, n--; /* Increment p, decrement n. */
}
}
» Tin mới nhất:
» Các tin khác: