Machine-translated by Google. Questions are authored in English.
Top

Embedded C Programming Questions and Answers

Answer: C

The cast widens the multiplication to thirty-two bits so no precision is lost, and the shift removes the extra fifteen fractional bits. Omitting the cast is the usual bug, since the multiplication would then be done in sixteen bits and overflow.

Please log in or register to report this question.

Answer: D

Since every byte is zero there is no need to store it in flash; the start-up code simply clears the region. Variables with non-zero initialisers go in .data, whose initial values are copied from flash to RAM before main runs.

Please log in or register to report this question.

Answer: A

It also sets the stack pointer and may configure the clock, and only then does it call main. Static variables that appear uninitialised at run time are almost always a symptom of this code having been skipped or misconfigured.

Please log in or register to report this question.

Answer: B

Correct answer: space in both flash and RAM

The variable lives in RAM so that it can be written, and its initial value must survive power-off, so a copy is held in flash and the startup code copies it across before main runs. A zero-initialised variable needs no flash copy, since the startup code simply clears that region - which is why zero initialisation is cheaper.

Please log in or register to report this question.

Answer: C

A failure or a fragmented heap appears after weeks in service rather than in test, and the worst-case timing of an allocation is hard to bound. Static allocation, or a pool of fixed-size blocks, gives both determinism and a compile-time guarantee that the memory exists.

Please log in or register to report this question.

Answer: D

Reading it is the only reliable way to discover why the image has grown, and it exposes the large table or the library function nobody expected to be linked in. It also reports the total against the device's capacity, which is the figure the headroom target refers to.

Please log in or register to report this question.

Answer: A

Correct answer: without parentheses, SQ(a + b) expands wrongly

The expansion is a + b * a + b, which by precedence is a + (b*a) + b rather than the square of the sum. Every macro parameter and the whole macro body need parentheses. Note also that this macro evaluates its argument twice, which is a separate hazard.

Please log in or register to report this question.

Answer: B

Correct answer: has a side effect, such as an increment

A macro using its argument twice evaluates whatever was passed twice, so SQ(i++) increments i twice and computes something other than a square. A function evaluates its arguments once before the call, which is one of the two reasons an inline function is preferred.

Please log in or register to report this question.

Answer: C

Correct answer: is type checked and evaluates its arguments once

Those two properties are what a macro lacks: the compiler checks the argument types against the parameters, and each argument is evaluated exactly once whatever the body does with it. inline is a request rather than a guarantee, and the resulting code is not necessarily smaller.

Please log in or register to report this question.

Answer: D

It forbids constructs whose behaviour is undefined, unspecified or merely easy to get wrong, such as the signed and unsigned comparison and the uninitialised variable. Compliance is checked by a static analyser and deviations are documented rather than silently taken.

Please log in or register to report this question.

Loading…
Tags: Embedded C Programming Questions and Answers || Embedded C Programming MCQ Questions and Answers || Embedded C Programming GK Questions and Answers || Embedded C Programming GK MCQ Questions || Embedded C Programming Multiple Choice Questions and Answers || Embedded C Programming GK || GK on Embedded C Programming || Embedded Systems Questions and Answers || Embedded Systems MCQ Questions and Answers || Embedded Systems GK Questions and Answers || GK on Embedded Systems