Intel Coding Round Questions with Solutions
Last updated 2026-11-19
A coding screen for a processor company often leans on C and C++ details: what an expression evaluates to, how integer promotion changes a comparison, how a destructor chain runs, and small bit tricks. This page has twelve practice problems in that style, each with a worked solution, its complexity and the usual mistake.
They are practice problems for the topics such rounds are commonly reported to include. They are not real papers. Pair this page with Intel interview questions and the topic page on bit manipulation interview questions.
How to approach output-prediction problems
Write the types next to every operand first. Most wrong answers come from missing an implicit conversion or a precedence rule, not from the logic. If the code contains an unsequenced modification, such as i++ + ++i, the correct answer is that the behaviour is undefined, and saying so is a full-credit answer.
For implementation problems, state the assumptions (32-bit int, two's complement), handle the edge case first and give the complexity.
Hiring status
Formats and dates change. For what Intel is hiring for at the moment, see Intel hiring and the company's own careers site, jobs.intel.com. Nothing on this page implies that a drive is open.
Intel Coding Round Questions with Solutions: questions with worked answers
1 Predict the output: a static local variable.
easyA static local is initialised once and keeps its value between calls. The three calls return 1, 2 and 3. A normal local would return 1 each time. The calls are made in separate declarations on purpose: the order in which function arguments are evaluated is unspecified, so printf of next(), next(), next() could print 3 2 1. Time and space are constant. Common mistake: believing the initialiser runs on every call.
c#include <stdio.h> int next(void) { static int n = 0; return ++n; } int main(void) { int a = next(), b = next(), c = next(); printf("%d %d %d\n", a, b, c); return 0; }2 Predict the output: post-increment and pre-increment used in separate statements.
easyint b = a++ copies 5 into b, then a becomes 6. int c = ++a makes a 7 and copies 7 into c. Output: 7 5 7. Do not combine both in one expression such as a++ + ++a, which is undefined behaviour because a is modified twice with no sequence point between the changes.
c#include <stdio.h> int main(void) { int a = 5; int b = a++; int c = ++a; printf("%d %d %d\n", a, b, c); return 0; }3 Predict the output: operator precedence with shifts and bitwise AND.
mediumAddition binds tighter than shift, so 1 << 2 + 1 is 1 << 3 = 8. Equality binds tighter than bitwise AND, so 5 & 3 == 3 is 5 & (3 == 3) = 5 & 1 = 1. Output: 8 1. Parenthesise bit expressions in real code. Common mistake: reading 5 & 3 == 3 as (5 & 3) == 3.
c#include <stdio.h> int main(void) { printf("%d %d\n", 1 << 2 + 1, 5 & 3 == 3); return 0; }4 Predict the output: signed and unsigned comparison.
mediumIn u + i, the int -10 is converted to unsigned, becoming 4294967286 on a 32-bit int, so the sum is 4294967291, which is greater than 0. The program prints greater, although the mathematical sum is negative. Fix by casting to a signed type or by comparing before adding. Common mistake: mixing size_t loop counters with negative values.
c#include <stdio.h> int main(void) { unsigned int u = 5; int i = -10; if (u + i > 0) puts("greater"); else puts("not greater"); return 0; }5 Isolate the lowest set bit and count trailing zeros of an unsigned integer.
easyx & -x (computed as x & (~x + 1)) keeps only the lowest set bit. The trailing-zero count is the position of that bit; GCC and Clang provide __builtin_ctz for non-zero input. For 40 (binary 101000) the lowest set bit is 8 and the trailing zeros are 3. Time O(1). Common mistake: calling __builtin_ctz(0), which is undefined.
c#include <stdio.h> int main(void) { unsigned x = 40; unsigned low = x & (~x + 1u); printf("%u %d\n", low, __builtin_ctz(x)); /* 8 3 */ return 0; }6 Swap two integers without a temporary using XOR. What breaks when both pointers refer to the same object?
mediuma ^= b; b ^= a; a ^= b swaps correctly for distinct objects. If a and b are the same address, the first step makes the value zero and it stays zero, so swap(&x, &x) destroys x. Guard with if (a != b). In practice a temporary is as fast and clearer, so use XOR only if asked. Time O(1).
c#include <stdio.h> void swap(int *a, int *b) { if (a != b) { *a ^= *b; *b ^= *a; *a ^= *b; } } int main(void) { int x = 3, y = 9; swap(&x, &y); swap(&x, &x); printf("%d %d\n", x, y); /* 9 3 */ return 0; }7 Add two non-negative integers without using the + operator.
mediumXOR gives the sum without carries, AND shifted left gives the carries. Repeat until there is no carry. For 13 + 5 the answer is 18. Use unsigned so that the left shift of a carry is well defined. Time O(32) = O(1), space O(1). Common mistake: using signed ints with negative operands and shifting into the sign bit.
c#include <stdio.h> unsigned add(unsigned a, unsigned b) { while (b) { unsigned carry = (a & b) << 1; a ^= b; b = carry; } return a; } int main(void) { printf("%u\n", add(13, 5)); /* 18 */ return 0; }8 Find the missing number in an array that holds 0..n except one value.
easyXOR all indices 0..n with all array values, or compare the sum n(n+1)/2 with the actual sum. XOR avoids overflow for large n. For {3, 0, 1} with n = 3 the missing value is 2. Time O(n), space O(1). Common mistake: an off-by-one in the loop bound, since the array has n elements but n + 1 candidate values.
c#include <stdio.h> int missing(const int *a, int n) { int x = n; for (int i = 0; i < n; i++) x ^= i ^ a[i]; return x; } int main(void) { int a[] = {3, 0, 1}; printf("%d\n", missing(a, 3)); /* 2 */ return 0; }9 Predict the output of a virtual destructor chain in C++.
mediumnew Der runs the base constructor and then the derived constructor. Deleting through a Base pointer calls the derived destructor first only because the base destructor is virtual, then the base destructor. Output: B D ~D ~B. Without virtual, only ~B runs and the behaviour is undefined. Time and space are constant. Common mistake: forgetting that base objects are constructed first and destroyed last.
cpp#include <iostream> struct Base { Base() { std::cout << "B "; } virtual ~Base() { std::cout << "~B "; } }; struct Der : Base { Der() { std::cout << "D "; } ~Der() { std::cout << "~D "; } }; int main() { Base *p = new Der; delete p; }10 Binary search that does not overflow, returning the first index of a target in a sorted array with duplicates.
mediumKeep the range [lo, hi) and compute mid = lo + (hi - lo) / 2, which cannot overflow, unlike (lo + hi) / 2 for large arrays. When a[mid] is at least the target, move hi to mid, otherwise lo to mid + 1. At the end, check lo against n and the value. Time O(log n), space O(1). Common mistake: returning on the first match and losing the leftmost position.
c#include <stdio.h> int first_index(const int *a, int n, int t) { int lo = 0, hi = n; while (lo < hi) { int mid = lo + (hi - lo) / 2; if (a[mid] >= t) hi = mid; else lo = mid + 1; } return (lo < n && a[lo] == t) ? lo : -1; } int main(void) { int a[] = {1, 2, 2, 2, 5, 7}; printf("%d %d\n", first_index(a, 6, 2), first_index(a, 6, 6)); /* 1 -1 */ return 0; }11 Transpose an N by N matrix in place, and say why a naive large transpose is slow.
hardSwap a[i][j] with a[j][i] only for j greater than i, otherwise each pair is swapped twice and the matrix returns to its original form. Time O(N^2), space O(1). For big matrices, the column accesses stride across cache lines, so blocking the loops into small tiles keeps both source and destination lines in cache. Common mistake: looping j from 0 and getting the original matrix back.
c#include <stdio.h> #define N 3 int main(void) { int a[N][N] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) { int t = a[i][j]; a[i][j] = a[j][i]; a[j][i] = t; } for (int i = 0; i < N; i++) printf("%d %d %d\n", a[i][0], a[i][1], a[i][2]); return 0; /* 1 4 7 / 2 5 8 / 3 6 9 */ }
Frequently asked questions
What language should I use for an Intel-style coding round?
Use C or C++ when the test allows it, as the topics lean on low-level behaviour. If the platform offers only Python or Java, the algorithmic problems here still apply, but the output-prediction ones are C specific.
How do I handle undefined-behaviour questions?
Say that the behaviour is undefined and explain why, for example a variable modified twice without sequencing or signed overflow. Then give what a defined version of the code would print.
Is this the real Intel paper?
No. These are practice problems in the style of topics commonly reported for such rounds, and Intel does not publish its papers.
How much time should I give each problem?
About five to ten minutes for output prediction and fifteen to twenty for implementation problems. Write the edge cases before you start coding.
Sources
Related guides
More in Company Interview Questions
- Intel Interview Questions and Answers for India Software Roles
- Intuit Coding Round Questions with Solutions in Python and Java
- Intuit Interview Questions and Answers for SDE-1 Roles
- JPMorgan Chase interview questions with answers (software engineer)
- JPMorgan coding round questions with solutions
- Juspay Coding Round Questions
- Juspay Interview Questions with Answers
- KPIT coding round questions
- KPIT interview questions and answers
- KPMG coding round questions
- KPMG interview questions and answers
- L&T Technology Services interview questions