Sasken coding round questions
Last updated 2026-11-19
Sasken has long built software for handsets, network equipment and other connected devices, so its work sits close to protocol stacks and low-level C. Candidates commonly report technical tests built around C: reading code and predicting output, pointer and memory questions, and short programs. Sasken has not published a syllabus we can cite. Everything below is our own practice set in that direction, not a leaked or recalled paper.
The twelve problems come from telecom firmware chores: framing bits on a link, parsing and comparing addresses, computing a header checksum, managing a pool of message buffers, and walking a linked list of connection records. Each routine was compiled with gcc and run on test inputs. The conversational side is in Sasken interview questions.
| Round style (commonly reported) | C-centred technical test with short programs |
|---|---|
| Practice difficulty | Easy to medium |
| Code shown | C, compiled and run with gcc |
Pointers are the common thread
Protocol code is mostly pointers walking buffers. A message arrives as bytes, you step a pointer through headers and payloads, and you hand sub-buffers to other layers. Sasken-style questions therefore reward a clear mental picture of what each pointer points at after every statement, and they punish guessing.
Draw boxes for memory cells and arrows for pointers on paper. For each line, redraw. It feels slow for the first week and then becomes the quickest way to get output-prediction questions right.
Telecom vocabulary used below
- Bit stuffing: a framing trick in which a zero is inserted after five consecutive ones so the data can never imitate a flag byte.
- IPv4 header checksum: the one's complement of the one's complement sum of the header's 16-bit words.
- Subnet mask: a pattern of leading ones that says which bits of an address identify the network.
- Memory pool: a fixed number of equal blocks handed out and returned without a general-purpose allocator.
More C revision
For extra output-prediction practice go to C programming interview questions. For list problems in other languages, see linked list interview questions.
Hiring status
We hold no sourced Sasken statement on fresher numbers, dates or eligibility, so none are stated. Confirm everything with your invitation and the company careers page.
Sasken coding round questions: questions with worked answers
1 Write atoi that skips leading spaces, accepts an optional sign and stops at the first non-digit, clamping to the int range instead of overflowing.
mediumAccumulate in a wider type. Use a 64-bit value, cap it once it exceeds 2^31 so it cannot overflow itself, apply the sign and clamp to INT_MIN and INT_MAX. O(length). The standard atoi has undefined behaviour on overflow, which is why clamping is the safer exercise. The usual mistakes are forgetting the sign, treating a lone sign as a number, and negating before the range check.
c#include <limits.h> int atoi_clamp(const char *s) { while (*s == ' ') s++; int neg = 0; if (*s == '+' || *s == '-') neg = (*s++ == '-'); long long v = 0; while (*s >= '0' && *s <= '9') { v = v * 10 + (*s++ - '0'); if (v > 2147483648LL) v = 2147483648LL; } if (neg) v = -v; if (v > INT_MAX) return INT_MAX; if (v < INT_MIN) return INT_MIN; return (int)v; }2 Convert an unsigned 32-bit value to text in any base from 2 to 16 without sprintf, writing into a caller-supplied buffer.
easyFill from the end. Repeatedly take the value modulo the base, map it to a character from a lookup string, and divide; digits come out least significant first, so write backwards from the end of the buffer and return a pointer to the first digit. O(digits). The buffer needs 33 bytes for base 2 including the terminator. A do-while loop handles zero correctly, whereas a while loop prints an empty string.
c#include <stdint.h> char *utoa_base(uint32_t v, unsigned base, char buf[33]) { char *p = buf + 32; *p = '\0'; do { *--p = "0123456789ABCDEF"[v % base]; v /= base; } while (v != 0); return p; }3 Given the head of a singly linked list of connection records that may contain a loop, return the node where the loop begins, or NULL if there is none.
mediumFloyd's two-speed pointers. Advance a slow pointer by one and a fast pointer by two; if they meet there is a loop. Then restart slow from the head and move both by one: they meet at the loop's first node. O(n) time, O(1) space. A hash set of visited nodes also works but needs O(n) space. Checking fast and fast->next before dereferencing both is essential, or a list with no loop crashes.
c#include <stddef.h> struct node { int val; struct node *next; }; struct node *loop_start(struct node *head) { struct node *slow = head, *fast = head; while (fast != NULL && fast->next != NULL) { slow = slow->next; fast = fast->next->next; if (slow == fast) { slow = head; while (slow != fast) { slow = slow->next; fast = fast->next; } return slow; } } return NULL; }4 Remove duplicate values from a sorted, heap-allocated singly linked list in place and free the removed nodes.
easyOne pass with a current pointer. While the current node has a successor, compare values: if equal, unlink the successor, free it and stay on the current node; otherwise advance. O(n) time, O(1) space. Advancing after every unlink skips a node when three equal values are in a row. Freeing a node before reading its next pointer is use-after-free, so save the next pointer first.
c#include <stdlib.h> struct item { int val; struct item *next; }; struct item *dedupe_list(struct item *head) { struct item *cur = head; while (cur != NULL && cur->next != NULL) { if (cur->val == cur->next->val) { struct item *dead = cur->next; cur->next = dead->next; free(dead); } else { cur = cur->next; } } return head; }5 Apply HDLC-style bit stuffing to an array of bits (one bit per byte): insert a 0 after every run of five consecutive 1s. Return the output length.
mediumCounter of consecutive ones. Copy each bit to the output; if it is a one, increment the run counter and when it reaches five append a zero and reset it; a zero resets the counter. O(n) time. The output can grow by up to n / 5 bits, so size the buffer for that. Resetting the counter after the inserted zero is a must, and a common slip is to count the stuffed zero as input.
c#include <stdint.h> #include <stddef.h> size_t bit_stuff(const uint8_t *in, size_t n, uint8_t *out) { size_t o = 0; int ones = 0; for (size_t i = 0; i < n; i++) { out[o++] = in[i]; if (in[i]) { if (++ones == 5) { out[o++] = 0; ones = 0; } } else { ones = 0; } } return o; }6 Parse a dotted IPv4 string into a 32-bit integer, rejecting bad input, and then test whether two addresses lie in the same subnet for a given prefix length.
mediumParse four parts, then mask. Read digits into a value no greater than 255, require a dot between parts and nothing after the last, and shift each part into place. Build the mask as all ones shifted left by 32 minus the prefix, taking care of prefix zero because a shift by 32 is undefined. Two addresses match when they agree under the mask. O(length). Using signed ints for the address makes the mask shift unreliable.
c#include <stdint.h> int parse_ipv4(const char *s, uint32_t *out) { uint32_t ip = 0; for (int part = 0; part < 4; part++) { if (*s < '0' || *s > '9') return 0; unsigned v = 0; int digits = 0; while (*s >= '0' && *s <= '9') { v = v * 10 + (unsigned)(*s++ - '0'); if (++digits > 3 || v > 255) return 0; } ip = (ip << 8) | v; if (part < 3) { if (*s != '.') return 0; s++; } } if (*s != '\0') return 0; *out = ip; return 1; } int same_subnet(uint32_t a, uint32_t b, unsigned prefix) { uint32_t mask = (prefix == 0) ? 0u : (0xFFFFFFFFu << (32u - prefix)); return (a & mask) == (b & mask); }7 Compute the Internet checksum used in an IPv4 header: the one's complement of the one's complement sum of all 16-bit big-endian words.
mediumSum words, fold carries, invert. Add the bytes pairwise as big-endian 16-bit words into a 32-bit accumulator, padding a final odd byte with zero in the low half, then repeatedly add the top 16 bits back into the bottom 16 until none remain, and take the complement. O(n). To verify a received header, sum it including the checksum field; the folded result before inversion is 0xFFFF. A classic slip is skipping the carry fold, or computing the checksum with the field not set to zero.
c#include <stdint.h> #include <stddef.h> uint16_t inet_checksum(const uint8_t *d, size_t len) { uint32_t sum = 0; size_t i = 0; for (; i + 1 < len; i += 2) sum += ((uint32_t)d[i] << 8) | d[i + 1]; if (len & 1u) sum += (uint32_t)d[len - 1] << 8; while (sum >> 16) sum = (sum & 0xFFFFu) + (sum >> 16); return (uint16_t)~sum; }8 Build a fixed pool of eight 32-byte message buffers with constant-time allocate and free and no malloc.
hardFree list threaded through the blocks. Define a union so a free block stores a next pointer in its own bytes, link all blocks at start-up, allocate by popping the head and free by pushing onto the head. Both are O(1) and fragmentation cannot happen. Freeing a block twice corrupts the list, and returning a pointer that did not come from the pool does the same, so a debug build should check that the address lies within the array.
c#include <stdint.h> #include <stddef.h> #define BLOCKS 8 #define BLOCK_SZ 32 union block { union block *next; uint8_t bytes[BLOCK_SZ]; }; static union block pool[BLOCKS]; static union block *free_list; void pool_init(void) { for (int i = 0; i < BLOCKS - 1; i++) pool[i].next = &pool[i + 1]; pool[BLOCKS - 1].next = NULL; free_list = &pool[0]; } void *pool_alloc(void) { union block *b = free_list; if (b != NULL) free_list = b->next; return b; } void pool_free(void *p) { union block *b = (union block *)p; b->next = free_list; free_list = b; }9 Write a generic swap that exchanges two objects of any type given their addresses and size in bytes.
easyByte-wise exchange through unsigned char pointers. Loop over the size, swapping one byte at a time, so no temporary buffer of unknown size is needed. O(size) time and O(1) space. Using memcpy with a variable-length temporary is the alternative but risks a large stack array. If both pointers are equal the loop swaps each byte with itself and is harmless; partially overlapping objects give undefined results.
c#include <stddef.h> void swap_bytes(void *a, void *b, size_t n) { unsigned char *x = (unsigned char *)a; unsigned char *y = (unsigned char *)b; while (n--) { unsigned char t = *x; *x++ = *y; *y++ = t; } }10 What does this program print, assuming a 4-byte int? int a[] = {10, 20, 30, 40}; int *p = a; int *q = a + 3; printf("%d ", *p++ + *q--); printf("%d %d ", *p, *q); printf("%ld %zu\n", (long)(q - p), sizeof a);
mediumIt prints 50 20 30 1 16. The first printf adds the old targets, 10 and 40, and then the post-increment moves p to a[1] and the post-decrement moves q to a[2]. The second line therefore shows 20 and 30. Pointer subtraction counts elements, not bytes: a + 2 minus a + 1 is 1. The array size is four ints of four bytes each, 16. Remember that sizeof on an array name gives the whole array, but on a function parameter it gives only the pointer size.
c#include <stdio.h> void demo(void) { int a[] = {10, 20, 30, 40}; int *p = a; int *q = a + 3; printf("%d ", *p++ + *q--); printf("%d %d ", *p, *q); printf("%ld %zu\n", (long)(q - p), sizeof a); }11 Remove every space from a string in place, keeping the other characters in order.
easyReader and writer pointers. The reader visits every character; the writer advances only for characters that are kept, and a terminator is written at the end. O(n) time, O(1) space. Building a new string wastes memory that a small device may lack. Calling a shifting routine for each space is O(n^2). The input must be a modifiable array, because writing into a string literal is undefined behaviour.
cvoid strip_spaces(char *s) { char *w = s; for (; *s != '\0'; s++) { if (*s != ' ') *w++ = *s; } *w = '\0'; }12 Find the length of the longest run of consecutive 1 bits in a 32-bit word, for example when measuring the longest burst in a status register.
easyShrink the runs. The expression x & (x << 1) shortens every run of ones by one bit, so counting how many times you can apply it before the word becomes zero gives the longest run length. At most 32 iterations, O(1) space. A bit-by-bit scan with a current-run counter also works. Using a signed type invites trouble when the top bit is set, so take an unsigned argument.
c#include <stdint.h> int longest_ones(uint32_t x) { int best = 0; while (x != 0) { x &= (x << 1); best++; } return best; }
Frequently asked questions
Is Sasken's test really all C?
Candidates frequently describe it as C-centred, especially for firmware roles, but this is a pattern from reports, not a rule. Your invitation states the languages and sections.
How should I prepare for output-prediction questions?
Trace by hand with boxes and arrows, then run the code to compare. Pay special attention to pointer arithmetic, operator precedence and integer promotion.
Why does the pool use a union?
A free block has no user data, so its own bytes can hold the next pointer. When allocated, the same bytes belong entirely to the caller.
Do I need to know telecom protocols for the test?
No. The protocol flavour is context. The techniques tested are bit handling, string and pointer work and list manipulation, which apply everywhere.
Where can I check the real Sasken hiring process?
On Sasken's careers page and in the mail you receive. This page contains no hiring numbers, dates or cutoffs.
Related guides
More in Company Interview Questions
- Sasken interview questions and answers
- ServiceNow Coding Round Questions With Solutions
- ServiceNow Interview Questions and Answers
- Siemens Coding Round Questions with Solutions
- Siemens Interview Questions and Answers for India Software Roles
- Sopra Steria coding round questions
- Sopra Steria interview questions and answers
- Sprinklr Coding Round Questions With Solutions
- Sprinklr Interview Questions and Answers
- Swiggy Coding Round Questions with Solutions
- Swiggy Interview Questions and Answers
- Synopsys Coding Round Questions with Solutions