embedded using c programming Interview Questions & Answers (1)

Embedded using C Interviews Questions and Answers

What is Embedded system? Describe Embedded C.

In simple words, Embedded system can be referred as customise hardware with customise software. Embedded systems are controller based which is embed with software to perform specific task.

Embedded C is extended version of C language which is used to develop micro- controller based systems.


What are little endian and big endian types of storage? How can you identify which type of allocation a system follows?

Big endian and little endian are two formats to store multibyte data types into computer’s memory. Big endian format and little endian format. In Big endian format msb(most significant byte) gets memory first and lsb (least significant byte) in last.

In case of little endian format the lsb byte gets memory first and msb byte in last.

Suppose an integer having value 0x12345678.

In case of big endian 0x12 gets stored first in memory, then  0x34 ,then 0x56 and in the last 0x78.

In case of little endian 0x78 gets stored first in memory, then  0x56 ,then 0x34 and in the last 0x12.

0x12 0x34 0x56 0x78
0x2000 0x2001 0x2002 0x2003 0x2004
Memory address
Big Endian Format
0x78 0x56 0x34 0x12
0x2000 0x2001 0x2002 0x2003 0x2004
Memory address
Little Endian Format


Write a C program to identify little and big endian.

#include <stdio.h>

int main ()


 unsigned int x = 0x12345678;

 char *c = (char*) &x;

 if (*c == 0x78)


   printf (“Architecture is little endian. \n);




    printf (“Architecture is big endian. \n);


 return 0;



What is ISR?

ISR refers to Interrupt service routine.Whenever an interrupt occurs, the controller completes the execution of the current instruction and starts the execution of an Interrupt Service Routine.This process is also known as interrupt handler.  


What is qualifier in C?

Qualifiers are the keywords which are used to modify the values of variables. There are two types of qualifier in C.


Const qualifier used with variable when we want to make variable to unchangeable. If you will try to change, compiler will give you error.


Variable qualified with volatile prevent the compiler to optimize that variable. Values of variable can be changed by code outside the scope of current code at any time.The system always reads the current value of a volatile object from the memory location rather than keeping its value in temporary register.


What is a ‘volatile’ variable, can variable be both constant and volatile, can a pointer be volatile ?

Consider the following example:

volatile int x;

When compiler finds the variable qualified with volatile qualifier, it is clearly comes to know to compiler that it will not be involved in any changing related to variable. The value of this variable can be changed anytime  by any external source.

A single variable can be const as well as volatile.Example

int volatile *const y;

y is a constant pointer to a volatile integer.

Yes, volatile pointers are possible in c.

int *volatile value;


What is interrupt latency? How to reduce interrupt latency?

Whenever microcontroller receives any interrupt, first it complete currently executing instruction , then provide service to interrupt and again continues the executing instruction from the same position where controller skipped .

So, it takes some time to microcontroller to provide service to interrupt. The amount of time(Number of cycle) taken by microcontroller to start servicing to interrupt known as interrupt latency.

Interrupt latency can be minimized by writing short ISR routine and by not delaying interrupts for more time.


Can we use any function inside the ISR?

Yes, we can but doing so will increase interrupt latency. That’s why it is not recommended as in many cases latency should be as small as possible and using function inside the ISR will also decrease performance.


What are storage classes?

Storage classes used to classify variable as per their scope (visibility) and  lifetime. Default value and storing value place also differ to each other. There are four types of storage classes.


Variable Scope Lifetime Default Value
Auto Local Within the function Garbage value
register Local Within the function Garbage value
Static Local Till the end of the program Zero
extern Global Till the end of the program Zero

Note: Only register variables get memory in CPU register (if CPU register has vacant memory). Other three variables get memory in RAM memory locations.


What is use of static keyword?

Static keyword can be used with variable as well as functions. The life of static variable lasts till the end of the programs and scope is local(Visible within the function only). Still static variable holds  their value after they are out of their scope.


int increment()


 static int count = 0;


 return count;



int main()


 printf(“%d “, increment());

 printf(“%d “, increment());

 return 0;


Output: 1 2

Function with static within any source file can accessible to only that source file.By using static we make function local only to source file within it is defined.


What is use of register storage class?

In register storage class cpu registers are used to store values.

for example. If you want to store variable which will be frequently require then you can store it in register like in case of loops.However it is not guaranteed that variable will get store in register.

It is like request to cpu to allow the variable to store in CPU’s register.

If CPU has vacant register to store variable ,it permits otherwise ignore the request and variable gets allocated in ram memory.

Note: We cannot obtain the address of a register variable using pointers.


What is Synchronous and asynchronous data transmission?

Serial data communication has two types.

Synchronous data transmission

Synchronous transmission needs a clock signal between the source and target to let the target know of the new byte.synchronous transmission data is transmitted in the form of data bundles. So data rate of it very high.

Asynchronous data transmission

Asynchronous transmission has no need of clock signal between the source and target. It sends start and stop bit to start and stop the transmission.It send single byte data at a time so data rate of it is not much good.

Synchronous vs. Asynchronous Transmission

  1. In synchronous mode data is transmitted in bundle but in asynchronous mode  data is transmitted byte by byte.
  2. Synchronous required a clock signal between the source and destination to acknowledge the destination about information while in asynchronous clock signal is not required.
  3. Data transfer rate of synchronous is faster compared to asynchronous .
  4. Synchronous mode has lower overhead compared to asynchronous transmission.


What is Baud Rate? How it is differ from Bit Rate?

In data communication, data are transferred along with signal. The number of signal transferred per second is known is Baud rate. Bite rate is number of bits (data) transferred per second. As a single signal may contain more than 1 bit while transferring the data. The relation between two is given below.

Bit rate = baud rate x the number of bit per baud


What is memory leak ?How we can avoid it?

Memory leak is a condition where programmer allocate memory in heap area by using dynamic memory allocation and forget two deallocate it.So, it is recommended to use free() function to deallocate memory which is allocated by dynamic memory allocation once the use of memory location is not further needed.


How to set, clear and toggle a single bit of variable?

Value represent initial variable and position represents the position of bit in variable.

Setting a Bit:

Value |= (1 << position)

Clearing a Bit:

Value &= ~ (1<<position)

Toggling a Bit:

Value ^= (1 << position)


What is Dynamic Memory Allocation(DMA)? What is difference between malloc() and calloc()?

Dynamic memory allocation (DMA) is process of allocation memory for variables at run time of program. This kind of allocation allocates memory in heap area of memory.

malloc function takes one argument at calling  but calloc takes two arguments. Also memory allocated by calloc is initialized with zero.


These function always return pointer of type void which can be cast into a pointer of any form.


Syntax: For 5 element of int type variable. ptr is int type pointer.

ptr = (int *) malloc (5*sizeof(int))

ptr =  (int*) calloc (5, sizeof(int))


What is void pointers in C?

Void pointer also known as generic pointers. There is no data type associated with these, so these can be typed cast to any types.


What is dangling pointer?

A pointer pointing to deleted or deallocated memory  location is known as dangling pointer. To try to access this type of pointer causes undefined behaviour or segmentation fault.


What is wild pointer?

An uninitialized pointer known as wild pointer. When we declare any pointer without giving any address, it shows an arbitrary memory location. As we assign it a memory location, it is not a wild pointer any more.


int main()


           int a;

           int* ptr;              //Wild pointer

           ptr = &a;           //Not more wild pointer




Explain the meaning of these pointers?


  • int *ptr;
  • cons int * ptr;
  • int * const ptr;
  • const int *const ptr;


int *ptr

It is a pointer to a variable. We can change the value pointer pointing to and also the value of ptr.


const int * ptr

It is pointer to a constant.  It can be also declare as int const *ptr. We can change pointer to point other variable but we can not change the value of it by using pointer.


int * const ptr

It is constant pointer to a variable. We can change the value of variable by using pointer but we can not change pointer to point other variable.  


const int *const ptr

It is constant pointer to a constant variable. Neither we can change pointer to point other variable nor we can change the value using pointer.




I’m Dhananjay — a free-spirit with a passion for technologies and blogging.

View all posts by Dhananjay →

3 thoughts on “Embedded using C Interviews Questions and Answers

  1. Amazing! This blog looks exactly like my old one! It’s on a entirely different topic but it has pretty much the same page layout and design. Wonderful choice of colors!|

  2. Attractive part of content. I simply stumbled upon your web site and in accession capital to say that I acquire actually loved account your weblog posts. Any way I’ll be subscribing for your augment and even I success you get entry to consistently fast.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.