LTTS coding round questions
Last updated 2026-11-19
L&T Technology Services engineers work on industrial automation, medical devices, rail, telecom and plant systems, and much of that firmware is written in C. Candidates commonly describe a test of aptitude and technical multiple-choice questions with a programming part that, for embedded profiles, leans towards C. LTTS has not published a syllabus we can cite, so this page offers practice in that direction and does not claim to reflect any real paper.
Twelve problems follow, all in C and all drawn from sensor and field-bus work: checksums for a serial link, joining 16-bit registers, packing converter samples, debouncing a switch. Every routine was compiled with gcc and run against test inputs. The interview side is covered in LTTS interview questions.
| Round style (commonly reported) | Aptitude, technical MCQs and basic coding, often in C |
|---|---|
| Practice difficulty | Easy to medium |
| Code shown | C, compiled and run with gcc |
Plant-floor firmware in a nutshell
A controller on a factory line reads sensors over a serial bus, filters the numbers, decides something and drives an output. The programming questions you meet are miniature versions of those steps. They test whether you can handle fixed-width integers, pick the right byte order, stay inside a memory budget and avoid undefined behaviour.
Use <stdint.h> types throughout and be ready to explain why. A plain int may be 16 bits on a small microcontroller, so a routine that works on a laptop can silently break on the target.
Habits that separate clean answers from fragile ones
- Shift unsigned values only. Right-shifting a negative signed number and shifting into the sign bit are both implementation-defined or undefined.
- Never shift by an amount equal to or greater than the type width; mask the count first.
- Widen before multiplying: cast one operand to the wider type so the product does not overflow midway.
- State the byte order of any multi-byte field the moment you read it.
- Avoid malloc in firmware examples; use fixed buffers and caller-supplied storage.
Extra reading
The wider C material is in C programming interview questions, and the bit-twiddling basics are in bit manipulation interview questions.
Hiring status
We hold no sourced LTTS statement on fresher numbers, dates or eligibility, so none appear here. Rely on your invitation and the company careers site.
LTTS coding round questions: questions with worked answers
1 Compute the CRC-16 used by Modbus RTU frames (polynomial 0xA001 reflected, initial value 0xFFFF) over a byte buffer.
mediumBitwise CRC. XOR each byte into the low byte of the register, then perform eight shift steps: if the lowest bit is set, shift right and XOR with 0xA001, otherwise just shift. O(8n) time, O(1) space. The check value for the ASCII text 123456789 is 0x4B37. On the wire the low byte is sent first, and mixing that order up is the commonest reason a handwritten CRC is rejected.
c#include <stdint.h> #include <stddef.h> uint16_t crc16_modbus(const uint8_t *buf, size_t len) { uint16_t crc = 0xFFFF; for (size_t i = 0; i < len; i++) { crc ^= buf[i]; for (int b = 0; b < 8; b++) { if (crc & 1u) crc = (uint16_t)((crc >> 1) ^ 0xA001u); else crc >>= 1; } } return crc; }2 A Modbus device reports a signed temperature in tenths of a degree in one 16-bit register, and a 32-bit energy counter spread over two registers, high word first. Write the conversions.
easyWiden then combine. The counter is the high register shifted left 16 bits ORed with the low register, with the high word cast to 32 bits before shifting. The temperature register is two's complement, so values at or above 0x8000 are negative; subtract 65536 instead of relying on an implementation-defined cast. Constant time. Some devices send the low word first, so confirm the word order in the datasheet.
c#include <stdint.h> uint32_t regs_to_u32(uint16_t hi, uint16_t lo) { return ((uint32_t)hi << 16) | lo; } int16_t reg_to_tenths(uint16_t r) { return (r & 0x8000u) ? (int16_t)((int32_t)r - 65536) : (int16_t)r; }3 Round an unsigned 32-bit value up to the next power of two, and test whether a value is already a power of two.
mediumSmear the bits. Subtract one, then OR the value with itself shifted right by 1, 2, 4, 8 and 16, so every bit below the top set bit becomes one; adding one then gives the next power. A power of two has exactly one set bit, so x & (x - 1) equals zero for it. Constant time. Zero must be special-cased, and inputs above 2^31 wrap to zero because the result needs 33 bits.
c#include <stdint.h> int is_pow2(uint32_t x) { return x != 0 && (x & (x - 1u)) == 0; } uint32_t next_pow2(uint32_t x) { if (x == 0) return 1; x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; return x + 1; }4 Convert a 32-bit value between big-endian and little-endian byte order without any library call.
easyMove each byte to its mirrored position with masks and shifts: byte 0 goes to bit 24, byte 1 to bit 16, and so on. The function is its own inverse. Constant time. Using a pointer cast to read the bytes in place can violate strict aliasing and alignment rules, so the shift version is the safer form. Forgetting to mask before shifting leaves stray bits in the middle bytes.
c#include <stdint.h> uint32_t swap32(uint32_t x) { return ((x & 0x000000FFu) << 24) | ((x & 0x0000FF00u) << 8) | ((x >> 8) & 0x0000FF00u) | ((x >> 24) & 0x000000FFu); }5 Smooth a noisy 16-bit sensor with a moving average over the last four samples, using fixed storage and no division by a variable on every call beyond the divide-by-count.
mediumRunning sum over a small ring. Keep the last four samples, a write index and a running total. On each new sample subtract the value being overwritten, add the new one, advance the index with a mask and return the total over the number of samples seen. Constant time per call and a 32-bit total prevents overflow. Recomputing the sum over all four values each time works but wastes cycles on a slow part.
c#include <stdint.h> typedef struct { uint16_t buf[4]; uint8_t idx; uint8_t count; uint32_t sum; } avg4_t; uint16_t avg4_push(avg4_t *a, uint16_t sample) { a->sum -= a->buf[a->idx]; a->buf[a->idx] = sample; a->sum += sample; a->idx = (uint8_t)((a->idx + 1u) & 3u); if (a->count < 4) a->count++; return (uint16_t)(a->sum / a->count); }6 An ADC delivers 12-bit samples. Pack two samples into three bytes for transmission and write the matching unpack routine.
mediumSplit the first sample across byte zero (its top eight bits) and the high nibble of byte one (its low four bits); the second sample fills the low nibble of byte one and all of byte two. Unpacking reverses the shifts. Constant time and 25 percent smaller than sending 16-bit words. Mask each sample to 12 bits first, otherwise stray high bits corrupt the neighbouring nibble.
c#include <stdint.h> void pack12(uint16_t a, uint16_t b, uint8_t out[3]) { a &= 0x0FFF; b &= 0x0FFF; out[0] = (uint8_t)(a >> 4); out[1] = (uint8_t)(((a & 0x0F) << 4) | (b >> 8)); out[2] = (uint8_t)(b & 0xFF); } void unpack12(const uint8_t in[3], uint16_t *a, uint16_t *b) { *a = (uint16_t)((in[0] << 4) | (in[1] >> 4)); *b = (uint16_t)(((in[1] & 0x0F) << 8) | in[2]); }7 A log holds sensor-ID readings where every ID appears twice except one from a faulty unit that appears once. Find the odd one out in O(n) time and O(1) space.
easyXOR cancels equal pairs. Because x ^ x is zero and XOR is commutative, folding every value together leaves only the unpaired one. O(n) time, O(1) space, no sorting or hash table. It only works when every other value appears an even number of times. Two unpaired values would need a split on a differing bit, which is a separate harder question.
c#include <stdint.h> #include <stddef.h> uint32_t find_unpaired(const uint32_t *ids, size_t n) { uint32_t r = 0; for (size_t i = 0; i < n; i++) r ^= ids[i]; return r; }8 Debounce a mechanical switch: report a new state only after the raw input has differed from the current state for N consecutive samples.
mediumCounter-based filter. If the raw value equals the accepted state, reset the counter. Otherwise increment it, and once it reaches N, accept the new state and reset. Constant time per sample, one byte of state per switch. Resetting the counter only on a change of raw value, rather than on agreement with the accepted state, lets a bouncing contact slip through after enough noisy edges.
c#include <stdint.h> typedef struct { uint8_t state; uint8_t cnt; } debounce_t; uint8_t debounce(debounce_t *d, uint8_t raw, uint8_t need) { raw = raw ? 1u : 0u; if (raw == d->state) { d->cnt = 0; } else if (++d->cnt >= need) { d->state = raw; d->cnt = 0; } return d->state; }9 Compute the even-parity bit for a byte, that is the bit that makes the total number of ones even.
easyFold the byte onto itself. XOR the byte with itself shifted right by four, then two, then one; the lowest bit is then the XOR of all eight bits, which is 1 when the count of ones is odd, and that is exactly the even-parity bit to append. Constant time with no loop. Counting bits in a loop is fine for correctness but slower, and returning the parity of the count instead of the bit to add inverts the answer.
c#include <stdint.h> uint8_t even_parity_bit(uint8_t b) { b ^= (uint8_t)(b >> 4); b ^= (uint8_t)(b >> 2); b ^= (uint8_t)(b >> 1); return b & 1u; }10 A thermistor is calibrated by a table of sorted raw readings xs[] and temperatures ys[]. Convert a raw reading by linear interpolation using integer arithmetic only, clamping outside the table.
mediumFind the segment whose upper raw value is at least the input, then compute y0 + (y1 - y0) x (in - x0) / (x1 - x0). Do the multiplication in 32 bits before dividing so precision is kept. O(n) for the scan, or O(log n) with binary search. Integer division truncates towards zero, which gives a half-step bias on negative slopes. Dividing before multiplying would flatten the curve into steps.
c#include <stdint.h> #include <stddef.h> int16_t interp(const int16_t *xs, const int16_t *ys, size_t n, int16_t in) { if (in <= xs[0]) return ys[0]; if (in >= xs[n - 1]) return ys[n - 1]; size_t i = 1; while (xs[i] < in) i++; int32_t dx = (int32_t)xs[i] - xs[i - 1]; int32_t num = ((int32_t)ys[i] - ys[i - 1]) * ((int32_t)in - xs[i - 1]); return (int16_t)(ys[i - 1] + num / dx); }11 Add two 8-bit unsigned values so the result stops at 255 instead of wrapping around, as a duty-cycle register might need.
easySaturating addition. Widen to 16 bits, add, and clamp the sum to 255 before narrowing. Constant time. Plain uint8_t addition wraps modulo 256, so 200 + 100 would give 44 and make a lamp suddenly go dark. A branch-free alternative adds in 8 bits and tests whether the result is smaller than an operand, which signals a wrap.
c#include <stdint.h> uint8_t sat_add8(uint8_t a, uint8_t b) { uint16_t s = (uint16_t)a + b; return s > 255u ? 255u : (uint8_t)s; }12 Rotate a 16-bit register value left by n positions, where n may exceed 15.
mediumCombine two shifts. Mask the count to the range 0 to 15, shift left by that count and OR with the value shifted right by 16 minus the count. Masking the right-hand shift too makes a rotate by zero safe, since a shift by the full width is undefined. Constant time. Skipping the mask on n is the usual bug, and so is forgetting that a uint16_t is promoted to int before the shift.
c#include <stdint.h> uint16_t rotl16(uint16_t v, unsigned n) { n &= 15u; return (uint16_t)((v << n) | (v >> ((16u - n) & 15u))); }
Frequently asked questions
Is C compulsory for the LTTS programming section?
Not necessarily. Candidates report that embedded profiles lean towards C or C++, while software profiles may allow other languages. The invitation lists what your test accepts.
Why are these answers written with uint8_t and uint16_t?
Fixed-width types make the behaviour the same on every target. A plain int can be 16 or 32 bits, which changes overflow and shift results.
Do I need to memorise the Modbus CRC?
Memorising the loop is easy once you see it is a bitwise polynomial division. Practise it until you can write it without thinking, and know the 0x4B37 check value.
How do I practise embedded C without hardware?
Compile each routine on your PC with gcc, drive it from a small main function and print results in hex. Everything here runs that way.
Where do I find real LTTS hiring facts?
On the LTTS careers site and in your invitation. This page states no hiring numbers, dates or cutoffs.
Related guides
More in Company Interview Questions
- MakeMyTrip Coding Round Questions
- MakeMyTrip Interview Questions with Answers
- Mastercard coding round questions with solutions
- Mastercard interview questions with answers (software engineer)
- Media.net Coding Round Questions With Solutions
- Media.net Interview Questions and Answers
- Meesho Coding Round Questions with Solutions
- Meesho Interview Questions and Answers
- Meta Coding Round Questions with Solutions in Python and Java
- Meta Interview Questions and Answers for SDE Roles
- Micron Coding Round Questions with Solutions
- Micron Interview Questions and Answers for India Software and Firmware Roles