Tata Elxsi C Programming with DSA Interview Questions & Answers
Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
About Tata Elxsi hiring for C Programming with DSA roles
Tata Elxsi is a Tata Group design and technology services company that works on product engineering for the automotive, media and communications, and healthcare industries. Its teams build embedded software, set-top box and streaming solutions, medical device software and user experience designs. In India it hires software, embedded, testing and design engineers, with a notable development centre in Thiruvananthapuram's Technopark.
For C Programming with DSA roles, this Tata Elxsi practice set focuses most on Linked Lists (6), Structures, Unions and File Handling (6), Arrays and Strings (6), C Basics, Data Types and Operators (4). It has 13 easy, 17 medium questions, so you can start easy and work up to the harder ones.
Company type
IT services
Headquarters
Bengaluru, India
Main India offices
Bengaluru, Thiruvananthapuram, Chennai, Pune
Tata Elxsi C Programming with DSA interview process
Online assessment (aptitude + technical)
Technical interview
Managerial round
HR round
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for Tata ElxsiStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
Flip each next pointer while walking the list.
typedef struct Node { int data; struct Node *next; } Node;
Node *reverse(Node *head) {
Node *prev = NULL, *cur = head;
while (cur) {
Node *next = cur->next;
cur->next = prev;
prev = cur;
cur = next;
}
return prev;
}
Time O(n), space O(1). The returned prev is the new head.
Bit fields let struct members use a specified number of bits, such as unsigned int ready : 1; unsigned int mode : 3;, which saves memory for flags. They are common in embedded code and protocol headers. However, bit ordering, padding and whether plain int bit fields are signed are implementation defined, so for portable hardware register or wire format access, explicit masks and shifts are safer.
03
What is the difference between char s[] = "hello" and char *s = "hello"?
char s[] = "hello" creates a modifiable array of 6 bytes, usually on the stack, initialised with a copy of the literal. char *s = "hello" makes a pointer to a string literal stored in read-only memory; modifying it is undefined behaviour and often crashes. Declare such pointers as const char * so the compiler catches accidental writes.
Quicksort is O(n log n) on average and very fast in practice with in-place partitioning, but O(n squared) in the worst case with poor pivots and not stable. Merge sort is always O(n log n) and stable but needs O(n) extra memory. Heap sort is O(n log n) worst case and in place but not stable and slower due to poor cache use. C's qsort is usually a tuned hybrid.
05
What are the basic data types in C and their typical sizes?
C has char (1 byte), short (usually 2), int (usually 4), long (4 on Windows, 8 on 64-bit Linux), long long (at least 8), float (4) and double (8). The standard only fixes minimum ranges, so sizes depend on the platform. Use sizeof to check and the fixed-width types from stdint.h such as int32_t and uint8_t when exact sizes matter.
06
What is structure padding and how can you reduce it?
The compiler inserts padding bytes between members so each one is aligned, which can make a struct larger than the sum of its members. struct { char a; int b; char c; } is usually 12 bytes instead of 6. Reduce padding by ordering members from largest to smallest alignment. Packing with __attribute__((packed)) removes padding but can slow access or fault on some CPUs.
A stack is a last in, first out structure with push, pop and peek operations, all O(1). It is used for function call frames, undo features, expression evaluation, balanced bracket checking, backtracking and depth first search. In C you implement it with an array and a top index, or with a linked list when the size is not known in advance.
08
What does it mean that arrays decay to pointers when passed to functions?
When you pass an array to a function, C passes only a pointer to its first element, not a copy of the array. So void f(int a[]) is the same as void f(int *a), sizeof a inside gives the pointer size and changes to elements affect the caller's array. Always pass the length as a separate parameter, such as f(arr, n).
09
How do you convert an infix expression to postfix?
Use the shunting yard algorithm with an operator stack. Output operands directly. For an operator, pop operators of higher precedence, or equal precedence if left associative, to the output, then push it. Push '(' and on ')' pop until the matching '('. At the end, pop all remaining operators. For example a + b * c becomes a b c * +. Postfix is easy to evaluate with a stack.
10
Write a C program that counts lines, words and characters in a file.
Read character by character with fgetc.
FILE *fp = fopen(path, "r");
if (!fp) { perror("fopen"); return 1; }
long lines = 0, words = 0, chars = 0;
int c, inWord = 0;
while ((c = fgetc(fp)) != EOF) {
chars++;
if (c == '\n') lines++;
if (isspace(c)) inWord = 0;
else if (!inWord) { inWord = 1; words++; }
}
fclose(fp);
printf("%ld %ld %ld\n", lines, words, chars);
c is int so EOF can be distinguished from valid bytes.
11
How do you check whether a linked list is a palindrome in O(1) extra space?
Find the middle with slow and fast pointers, reverse the second half in place, then compare the first half and the reversed second half node by node. Finally reverse the second half again to restore the list, which interviewers appreciate. Time is O(n) and extra space is O(1). A simpler O(n) space approach copies values into an array or stack first.
12
Write a function that dynamically allocates an array of n integers and fills it with squares.
Check the allocation and let the caller free it.
int *makeSquares(size_t n) {
int *arr = malloc(n * sizeof *arr);
if (arr == NULL) return NULL;
for (size_t i = 0; i < n; i++) {
arr[i] = (int)(i * i);
}
return arr;
}
// caller
int *a = makeSquares(10);
if (a) { /* use */ free(a); }
Count transitions from space to non-space.
#include <ctype.h>
int countWords(const char *s) {
int count = 0, inWord = 0;
for (; *s; s++) {
if (isspace((unsigned char)*s)) {
inWord = 0;
} else if (!inWord) {
inWord = 1;
count++;
}
}
return count;
}
This handles multiple spaces, tabs and leading or trailing spaces correctly.
14
Why is a circular queue better than a simple array queue?
In a simple array queue, the front moves forward as elements are removed, so the space before it is wasted and the queue appears full even when there is room. A circular queue wraps indexes using modulo, so rear = (rear + 1) % size reuses freed slots. You track fullness with a count or by keeping one slot empty to distinguish full from empty.
Sliding window solves problems on contiguous subarrays or substrings by keeping a window with two indexes and moving them forward instead of rechecking every subarray. A fixed window finds things like the maximum sum of k elements, while a variable window expands and shrinks, as in the longest substring without repeating characters. It turns O(n squared) brute force into O(n).
16
What is the time complexity of common linked list operations?
Access or search by value is O(n). Insert or delete at the head is O(1). Insert at the tail is O(1) if you keep a tail pointer, otherwise O(n). Deleting a given node is O(1) in a doubly linked list but O(n) in a singly linked list, since you must find the previous node. Finding length is O(n) unless you store a count.
17
How do you set, clear and toggle a particular bit in C?
Use bit masks with shift operators.
x |= (1u << n); // set bit n
x &= ~(1u << n); // clear bit n
x ^= (1u << n); // toggle bit n
int bit = (x >> n) & 1u; // read bit n
Use unsigned types so shifts are well defined. These operations are common in embedded code for configuring hardware registers.
18
Tell me about a project where you worked with files or binary data in C.
Situation: in my final year project we logged GPS data on a microcontroller SD card. Task: store records reliably with small memory. Action: I designed a packed 16 byte record with fixed-width types, wrote it with a checksum, flushed every ten records and wrote a PC tool to decode the file. Result: we logged a full day with no corruption and could replay any trip.
19
Write code to check whether the machine is little endian or big endian.
Look at the first byte of a known integer.
int isLittleEndian(void) {
uint32_t x = 1;
unsigned char *p = (unsigned char *)&x;
return p[0] == 1;
}
// using a union
union { uint32_t i; unsigned char c[4]; } u = { 1 };
int little = (u.c[0] == 1);
x86 and most ARM systems are little endian; network byte order is big endian.
20
Your linked list program crashes when deleting the last node. What do you check?
Check that the previous node's next pointer is set to NULL after freeing the last node, that the tail pointer is updated if you keep one and that you do not access the node after free. Also handle the case of a one-node list where head itself must become NULL, which requires passing a pointer to the head pointer. Run the code under AddressSanitizer to find invalid accesses.
21
You must schedule the maximum number of non-overlapping meetings in one room. What algorithm do you use?
This is activity selection, solved greedily. Sort meetings by end time, then pick each meeting whose start is not earlier than the end of the last picked one. Choosing the earliest finishing meeting always leaves the most room for the rest, which can be proven by an exchange argument. Sorting dominates, giving O(n log n) time.
22
How would you detect if two linked lists intersect and find the intersection node?
Two lists intersect if they share a node by address, not just value. Compute both lengths, advance the longer list by the difference, then move both together until the pointers are equal. A neat trick is to walk pointer a through list A then B, and pointer b through B then A; they meet at the intersection or both reach NULL. Both are O(m + n) time and O(1) space.
23
Write a function that swaps two integers using pointers.
Pass addresses so the function can modify the caller's variables.
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main(void) {
int x = 3, y = 7;
swap(&x, &y);
printf("%d %d\n", x, y); // 7 3
return 0;
}
C passes everything by value, so pointers are needed to change caller data.
24
How do you find the middle of a linked list in one pass?
Use slow and fast pointers starting at the head. Move slow by one node and fast by two nodes each step. When fast reaches the end or NULL, slow is at the middle. For an even number of nodes this gives the second middle; start fast at head->next to get the first middle instead. It takes O(n) time and O(1) space.
25
What is the two-pointer technique and when is it used?
Two pointers keep two indexes that move through an array according to a rule, often from both ends of a sorted array or at different speeds. It solves pair sum on sorted arrays, removing duplicates in place, reversing, merging sorted arrays and partitioning. It usually gives O(n) time and O(1) extra space instead of nested loops.
26
What is the difference between const int *p, int *const p and const int *const p?
const int *p is a pointer to a constant int: you cannot change the value through p, but p can point elsewhere. int *const p is a constant pointer: p always points to the same address, but the value can change. const int *const p fixes both. Read declarations from right to left to understand them. const pointers to data are common in function parameters.
27
A program that writes logs with fprintf loses the last lines when it crashes. Why, and how do you fix it?
stdio streams are buffered, so fprintf stores data in memory and writes it to disk only when the buffer fills, the file closes or fflush is called. A crash loses whatever is still in the buffer. Call fflush after important log lines, set line buffering with setvbuf(fp, NULL, _IOLBF, 0) or write critical messages to unbuffered stderr. For durability on disk, add fsync on POSIX systems.
Compare character by character until a difference or the end.
int my_strcmp(const char *a, const char *b) {
while (*a && *a == *b) {
a++;
b++;
}
return (unsigned char)*a - (unsigned char)*b;
}
Casting to unsigned char matches the standard behaviour for characters above 127. It returns zero if equal, negative if a sorts first and positive otherwise.
29
Write a C function to check whether a number is an Armstrong number.
Sum of digits raised to the number of digits equals the number.
int isArmstrong(int n) {
int digits = 0, t = n, sum = 0;
while (t) { digits++; t /= 10; }
t = n;
while (t) {
int d = t % 10, p = 1;
for (int i = 0; i < digits; i++) p *= d;
sum += p;
t /= 10;
}
return sum == n;
}
For example 153 = 1 + 125 + 27.
In-order visits left, node, right and gives sorted output for a BST. Pre-order visits node, left, right and is used to copy or serialise a tree. Post-order visits left, right, node and is used to delete a tree or evaluate expression trees. Level-order visits nodes level by level using a queue. The first three are depth first and use recursion or an explicit stack.
Tips to crack the Tata Elxsi C Programming with DSA interview
Revise C, C++ or Python fundamentals along with operating systems and networking basics for embedded and media engineering roles.
Prepare a crisp walkthrough of your best project, focusing on the problem, your contribution and what you would improve now.
Read about Tata Elxsi's work in automotive software, video streaming and medical devices to show real interest in its domains.
Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
Practise the hard questions on this page aloud; Tata Elxsi interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the Tata Elxsi C Programming with DSA interview?
Candidates usually go through 4 stages: Online assessment (aptitude + technical); Technical interview; Managerial round; HR round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.
Which topics should I prepare for the Tata Elxsi C Programming with DSA interview?
This practice set leans on Linked Lists (6), Structures, Unions and File Handling (6), Arrays and Strings (6), C Basics, Data Types and Operators (4). Revise those first, then practise explaining one or two of your own projects end to end, because most Tata Elxsi interviewers ask you to walk through real work.
Are these the exact questions asked at Tata Elxsi?
No. These are curated practice questions that match the skills and difficulty usually tested in it services interviews like Tata Elxsi's. They are not a leaked or verified list of past questions.
Where does Tata Elxsi hire C Programming with DSA professionals in India?
Tata Elxsi has large teams in Bengaluru, Thiruvananthapuram, Chennai, Pune. Openings and locations change often, so check the Tata Elxsi careers page and filter by city and experience.
C Programming with DSA questions for similar companies