Embedded C MCQ Banner

Embedded C Multiple Choice Questions (MCQs) and Answers

Master Embedded C with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Embedded C concepts. Begin your placement preparation journey now!

Q61

Q61 What will the following code do?
void attribute((interrupt)) ISR(void) { /* code */ }

A

Generates a warning

B

Executes as ISR

C

Throws an error

D

Creates a function

Q62

Q62 Which instruction enables global interrupts in a typical microcontroller?

A

SETI

B

EI

C

CLI

D

RESET

Q63

Q63 What will happen with this code?
void ISR() { static int count = 0; count++; }

A

Count resets to 0

B

Count increments

C

Error

D

Infinite loop

Q64

Q64 How does this ISR behave?
void ISR(void) { if (flag)
{
return;
} flag = 1; }

A

Executes once

B

Executes only if flag is 0

C

Infinite loop

D

Error

Q65

Q65 An interrupt fails to trigger the ISR. What is the most likely cause?

A

ISR not defined

B

Global interrupts disabled

C

Wrong interrupt vector

D

ISR is improperly linked

Q66

Q66 A high-priority interrupt delays the execution of a low-priority interrupt. What is this behavior called?

A

Interrupt nesting

B

Interrupt masking

C

Interrupt priority

D

Interrupt queueing

Q67

Q67 A system hangs after an interrupt. What could be the issue?

A

Infinite loop in ISR

B

Stack overflow

C

Incorrect return address

D

Uncleared interrupt flag

Q68

Q68 Which type of memory is used to store variables that are initialized during runtime?

A

ROM

B

RAM

C

EEPROM

D

Flash Memory

Q69

Q69 What is the primary purpose of the stack in memory management?

A

To store instructions

B

To store global variables

C

To store function call data

D

To store static variables

Q70

Q70 What happens when a memory leak occurs in an embedded system?

A

Memory is automatically freed

B

Memory becomes unavailable

C

Memory remains unused

D

Memory is recycled

Q71

Q71 Which memory region is used for dynamically allocated memory in embedded systems?

A

Stack

B

Heap

C

Code Segment

D

Data Segment

Q72

Q72 What is the purpose of memory-mapped I/O in embedded systems?

A

To execute code

B

To access peripherals

C

To allocate memory

D

To store global variables

Q73

Q73 What will this code do?
int *ptr = malloc(sizeof(int));
if(ptr == NULL)
printf("Error");

A

Allocates memory

B

Prints "Error"

C

Does nothing

D

Throws an error

Q74

Q74 What will happen if free() is called on a NULL pointer?

A

Segmentation fault

B

Program crashes

C

Nothing happens

D

Memory is corrupted

Q75

Q75 What will be the output of the code?
int *p = (int *)malloc(4);
*p = 10;
free(p);
printf("%d", *p);

A

10

B

Garbage value

C

0

D

Segmentation fault

Q76

Q76 How does this code behave?
int arr[5];
printf("%d", arr[10]);

A

Prints 0

B

Segmentation fault

C

Garbage value

D

Error

Q77

Q77 A dynamically allocated memory block is accessed after being freed. What could be the consequence?

A

Memory corruption

B

Segmentation fault

C

Undefined behavior

D

Reduced performance

Q78

Q78 A stack overflow occurs in an embedded system. What is the most likely reason?

A

Too many function calls

B

Global variable overflow

C

Incorrect malloc usage

D

Heap corruption

Q79

Q79 A program exhibits random crashes. Debugging reveals issues with dangling pointers. What causes this?

A

Uninitialized variables

B

Memory freed incorrectly

C

Incorrect pointer arithmetic

D

Heap overflow

Q80

Q80 What is the primary purpose of a timer in embedded systems?

A

Generate delays

B

Store data

C

Handle interrupts

D

Enable memory management

Q81

Q81 Which of the following registers typically stores the current value of a timer?

A

Control register

B

Data register

C

Timer register

D

Interrupt flag register

Q82

Q82 What is the role of a prescaler in timer programming?

A

Increase timer frequency

B

Reduce timer resolution

C

Divide clock frequency

D

Store timer values

Q83

Q83 What is the difference between a timer and a counter in embedded systems?

A

Timer uses external events

B

Counter uses internal clock

C

Timer uses internal clock

D

No difference

Q84

Q84 Which mode in a timer is used to generate a Pulse Width Modulation (PWM) signal?

A

Overflow mode

B

Capture mode

C

Compare mode

D

Normal mode

Q85

Q85 What will the following code do?
TCCR0 |= (1 << CS01);

A

Starts timer with prescaler

B

Stops the timer

C

Resets the timer

D

Enables timer interrupt

Q86

Q86 What will happen in this code?
if (TIFR & (1 << TOV0)) { TIFR |= (1 << TOV0); }

A

Stops timer overflow

B

Resets timer overflow flag

C

Starts timer overflow

D

Configures timer overflow

Q87

Q87 What does this configuration do?
TCCR1A = 0x00; TCCR1B = (1 << CS10);

A

Enables timer with no prescaler

B

Configures PWM

C

Stops timer

D

Enables interrupt

Q88

Q88 What will happen in this code?
OCR0 = 100;
while (1) {
if (TCNT0 == OCR0) PORTB ^= (1 << PB0);
}

A

Toggles PB0 at 100 counts

B

Toggles PB0 at 255 counts

C

No output

D

Infinite loop

Q89

Q89 A timer fails to start in your program. What is the likely reason?

A

Incorrect prescaler

B

Interrupt not enabled

C

Timer overflow

D

Wrong initialization

Q90

Q90 A timer generates incorrect delays. What could be the possible cause?

A

Incorrect clock frequency

B

Incorrect timer mode

C

Wrong prescaler

D

All of these

ad verticalad vertical
ad