# 3K

Embedded Software Engineer interview questions shared by candidates

## Top Interview Questions

Sort: Relevance|Popular|Date
Embedded Software Engineer was asked...21 May 2020

### Given the following struct definition in C, what would sizeof(myStruct) return? typedef struct { short a; long b; char c; } myStruct;

For the 64 bit system, typedef struct { short a; //2 bytes long b; //8 bytes char c; //1 bytes } As alignment is due to largest type : 2 bytes(short) + 6bytes(padding to achieve 8 byte boundry) + 8bytes(long) + 1byte(char) + 7 bytes(extra padding to achieve 8 byte boundry) = 24bytes Less

if we using 32 bit the answer defiantly will be 7+1 for padding -&gt; 8 bytes if we using 64 bit the answer will be 17+7 for padding =24 bytes Less

(Hint: you have to keep in mind the rules of byte padding since #pragma pack(1) is not called) Less

### reverse bits of an integer that is a power of 2 , keeping complexity in mind.

int reverse(int n) { int msb=Math.log(n)/Math.log(2); return Math.pow(2, 32-msb); } Less

rev_n = n ^ (~(n*0));

if the bits that need to be reversed are just the ones to the right of the 1 so all you need to do is: return n -1; 1000 -&gt; 0111 1 -&gt; 0 10 -&gt; 1 10000000 -&gt; 1111111 Less

### What are different types of interrupts?

software interrupts hardware interrupts

External &amp;Internal Interrupt

1- External Interrupts: These types of interrupts generally come from external input / output devices which are connected externally to the processor. They are generally independent and oblivious of any programming that is currently running on the processor. 2- Internal Interrupts: They are also known as traps and their causes could be due to some illegal operation or the erroneous use of data. Instead of being triggered by an external event they are usually triggered due to any exception that has been caused by the program itself. Some of the causes of these types of interrupts can be due to attempting a division by zero or an invalid opcode etc. 3- Software interrupts: These types if interrupts can occur only during the execution of an instruction. They can be used by a programmer to cause interrupts if need be. The primary purpose of such interrupts is to switch from user mode to supervisor mode. Less

### Q1- Use of Volatile keyword?

volatile your a. ., does that count I used it

"volatile" keyword in C/C++ is used for any variable whose value can change anytime unexpectedly for example variables used in ISR, Memory mapped peripheral registers and variables used by multiple threads in RTOS based applications. Less

### why should i hire you

i too attened the interview on the same date . Now i have been called for managerial round. what questions thy asked u in managerial round. can u please tell Less

they asked puzzles based on real time scenario.they will check your attitude and decision making skills. Less

when you attended the interview .is it on 30th may 2015 ?

### will cache affect memory I/O register?

cache affects memory I/O reg. When using peripherals you want memory accesses to happen in a certain order (mostly because of hardware constraints) so you want to avoid reordering. This is exactly what you would expect cache to do; temporarily store instructions and perform optimizations by grouping/reordering. You might get unexpected errors because of this. Less

Depends if the I/O register is memory mapped, processor type and a host of other things.. Less

this is related to cache coherency.

### A brain teaser question where we have to find out 45 minutes with the help of two ropes. Given that one rope burns completely in 1 Hr and the rate or burning is not consistent.

Burn first rope from both ends, and second rope from one end only. When First has completely burned, 30 mins will have passed and second rope will have 30 mins left on it. Now burn second rope, which has burned for 30 mins already, from both ends, this will burn a 30 minute rope at twice speed, making it complete in 15 mins. This will be 45 minutes total. Less

I've faced same question in ASSIA interview

I assume that both ropes have the same non consistency. If you burn from one end it takes 1H. If you burn the first rope from both ends it takes 1/2 H. Immediately after the first rope burnt, burn the second rope from one end and the middle point that fires reached each other in the first rope. To get 1/4 H, burn it from both ends and the point that in the first rope the fires got together. Less

### What does memcpy return?

It returns an integer - the status of the operation

The key in these questions is to cover the fundamentals, and be ready for the back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Fitbit or ex-Fitbit Embedded Software Engineer experts on Prepfully? They give real-world practice and guidance, which is pretty helpful. prepfully.com/practice-interviews Less

A pointer to dest so that memcpy could be used as an argument in another function. Less

### “You have all of the prices for a given stock for the next year. You can buy once and sell once in that year. How do you determine when to buy and sell to maximize your profit?”

That answer does not work if the lowest price occurs _after_ the highest price. You have to evaluate the difference in price for each combination of days and find out which one results in the highest gain. You always assume that for whichever day you buy, the sell date will be _after_ that date. So you compare day 1 with days 2-365 and find the max gain for those combinations. Then you do the same for a buy on day 2, 3...etc. You'll end up with 364 max value date pairs. Now sort for the highest and use that combination for your best gain. Too bad it doesn't work that way in real life :) Less

Buy when its at the lowest and sell when its at the highest.

Declined