83%(6)Il 83% ha trovato utile questo documento (6 voti)
5K visualizzazioni3 pagine
The document contains multiple choice questions about C programming concepts such as preprocessor macros, pointers, volatile keyword usage, bit manipulation, and direct physical memory access. It tests knowledge of portable and flexible macro definitions, pointer and array declarations, static keyword usage, const qualifiers, volatile usage for peripherals and interrupts, resetting bits, compiler support for volatile const, and writing values to physical memory addresses.
The document contains multiple choice questions about C programming concepts such as preprocessor macros, pointers, volatile keyword usage, bit manipulation, and direct physical memory access. It tests knowledge of portable and flexible macro definitions, pointer and array declarations, static keyword usage, const qualifiers, volatile usage for peripherals and interrupts, resetting bits, compiler support for volatile const, and writing values to physical memory addresses.
The document contains multiple choice questions about C programming concepts such as preprocessor macros, pointers, volatile keyword usage, bit manipulation, and direct physical memory access. It tests knowledge of portable and flexible macro definitions, pointer and array declarations, static keyword usage, const qualifiers, volatile usage for peripherals and interrupts, resetting bits, compiler support for volatile const, and writing values to physical memory addresses.
Q: Which of the following is the most flexible way to declare a C preprocessor macro that takes two arguments and returns the smaller of their two values? Answers Correct Answer User Answer #define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MIN(A, B) { if (A < B) A; else B; }
#define MIN(A, B) ((A < B) ? A : B)
#define MIN(A, B) A < B ? A : B;
Q: Which of the following constructs can be used to create a portable infinite loop in C? Answers Correct Answer User Answer while (1) { ... }
for (;;) { ... }
loop: ... goto loop;
All of the above
Q: Which of the following statements accurately describes the intended effect of the declaration int (* a)[10];? Answers Correct Answer User Answer An array of ten integers
A pointer to an array of ten integers
An array of ten pointers to integers
An array of ten pointers to functions
Q: Which of the following statements accurately describes a use of C's static keyword? Answers Correct Answer User Answer
A variable declared static within the body of a function maintains its value between function invocations
A variable declared static outside the body of a function can only be
Answers Correct Answer User Answer
accessed by functions within the same module. Both of the above are accurate
Neither of the above are accurate; static is used for function declarations
Q: Which of the following statements accurately describes the meaning of the declaration int * const x;? Answers Correct Answer User Answer x is a constant pointer to an integer
x is a pointer to a constant integer
x is a constant integer value
None of the above; it's an invalid C declaration
Q: Which of the following items should generally be declared using C's volatile keyword? Answers Correct Answer User Answer
A memory-mapped peripheral status register
A global variable used within an interrupt service routine
A global variable used by multiple tasks in a multi-threaded application
All of the above
Q: Which of the following code snippets can be used to reset the least-significant bit of x? Answers Correct Answer User Answer x & 0x01;
x & ~0x01;
x | ~0x01;
x &= ~0x01;
Q: Which ANSI C compilers allow a variable to be declared both volatile and const? Answers Correct Answer User Answer All ANSI C compilers allow this
No ANSI C compilers allow this; it is a K&R C holdover
Most ANSI C compilers allow this
Only the GNU C compiler allows this
Q: Which of the following is a correct way to write the value 0xAA55 to physical memory address 0x67A9? Answers Correct Answer User Answer uint16_t * p = (uint16_t *) 0x67A9; p = 0xAA55;