Autocoder

Bosch Coding Round Questions with Solutions

Last updated 2026-11-19

Technical tests for automotive and embedded roles ask for code that resembles what runs on an ECU: pull a signal out of a CAN payload, scale a raw value to a physical unit, check a rolling counter, interpolate a calibration table. Alongside those come the C output-prediction snippets that every embedded test uses. This page has twelve practice problems in that style, each with a complete solution, complexity and the common mistake.

They are practice problems in the style of topics such tests are commonly reported to include, not real papers. For concepts see Bosch interview questions, and for the company's process see how to crack the Bosch interview.

How to approach them

Write down the data layout before the code: which byte, which bit, which byte order. Most ECU bugs are in the interpretation of a field, not in the arithmetic. State the type of every intermediate value and where it could overflow.

Handle the boundary: the first and last table entry, the counter wrap, the empty payload. In safety-minded code, an out-of-range input returns an error and a safe value rather than undefined behaviour.

Hiring status

Bosch India's own pages describe its Graduate Apprentice and Technical Management Trainee programmes, with a written test and technical and personal interview for the former; see Bosch interview questions for the sourced details. This page quotes no drive dates, openings or package figures.

Bosch Coding Round Questions with Solutions: questions with worked answers

  1. 1

    Predict the output: a static variable and a normal local variable in a function.

    easy

    The static counter keeps its value between calls and is initialised once, while the automatic counter is created fresh on each call. Three calls print s=1 a=1, s=2 a=1, s=3 a=1. Time and space are constant. Common mistake: expecting the local to accumulate, or the static to be re-initialised on every call.

    c
    #include <stdio.h>
    void tick(void) {
        static int s = 0;
        int a = 0;
        s++; a++;
        printf("s=%d a=%d\n", s, a);
    }
    int main(void) { tick(); tick(); tick(); return 0; }
  2. 2

    Predict the output: pointer arithmetic on a two-dimensional array.

    medium

    m is an array of 2 rows of 3 ints. *(m + 1) is the second row, and *(*(m + 1) + 2) is its third element, 6. m[0][1] is 2. sizeof(m[0]) is the size of one row, 12 bytes with 4-byte ints. Output: 6 2 12. Common mistake: thinking m + 1 advances by one int rather than by one whole row.

    c
    #include <stdio.h>
    int main(void) {
        int m[2][3] = {{1, 2, 3}, {4, 5, 6}};
        printf("%d %d %zu\n", *(*(m + 1) + 2), m[0][1], sizeof(m[0]));
        return 0;
    }
  3. 3

    Predict the output: a macro with an unparenthesised argument.

    medium

    SQUARE(3 + 1) with the definition x * x would expand to 3 + 1 * 3 + 1, which is 7. With the parenthesised definition ((x) * (x)) it is 16. The first call below uses the bad macro and the second the good one. Output: 7 16. Common mistake: believing macros evaluate their arguments first as functions do.

    c
    #include <stdio.h>
    #define BAD(x)  x * x
    #define GOOD(x) ((x) * (x))
    int main(void) {
        printf("%d %d\n", BAD(3 + 1), GOOD(3 + 1));
        return 0;
    }
  4. 4

    Extract a signal from a CAN payload: start bit 12, length 10, little-endian (Intel) layout.

    medium

    In the Intel layout bit 0 is the least significant bit of byte 0 and bits increase through the bytes. Treat the eight bytes as one 64-bit little-endian integer, shift right by the start bit and mask the length. For payload bytes 00 F0 3F 00 00 00 00 00 the 64-bit value is 0x3FF000, shifting by 12 gives 0x3FF, so the signal is 1023. Time O(1). Common mistake: mixing up the Intel and Motorola bit numbering conventions.

    python
    def extract(payload, start, length):
        v = int.from_bytes(payload, "little")
        return (v >> start) & ((1 << length) - 1)
    
    p = bytes([0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00])
    print(extract(p, 12, 10))  # 1023
  5. 5

    Convert a raw signal to a physical value: physical = raw x factor + offset.

    easy

    For a vehicle speed with factor 0.01 and offset 0, raw 8000 means 80.00 km/h. For a temperature with factor 0.5 and offset -40, raw 130 means 25.0 degrees. On integer-only targets, keep the value in hundredths: speed_x100 = raw. Time O(1). Common mistake: applying the offset before the factor, or computing in integer arithmetic where the factor truncates to zero.

    c
    #include <stdio.h>
    int main(void) {
        unsigned raw_speed = 8000, raw_temp = 130;
        double speed = raw_speed * 0.01;
        double temp = raw_temp * 0.5 - 40.0;
        printf("%.2f %.1f\n", speed, temp); /* 80.00 25.0 */
        return 0;
    }
  6. 6

    Validate a 4-bit rolling message counter that wraps from 15 to 0.

    medium

    The next valid value is (prev + 1) & 0xF. Receiving the same value again means a repeated frame; any other value means one or more messages were lost. For the sequence 14, 15, 0, 1, 3 the first four are valid and the last has a gap. Time O(1) per frame. Common mistake: comparing with prev + 1 without the wrap mask, which flags every 15 to 0 transition as a fault.

    python
    def check(seq):
        out = []
        for prev, cur in zip(seq, seq[1:]):
            out.append("ok" if cur == (prev + 1) & 0xF else "gap")
        return out
    
    print(check([14, 15, 0, 1, 3]))  # ['ok', 'ok', 'ok', 'gap']
  7. 7

    Interpolate a 1D calibration table (x increasing) with integer arithmetic.

    hard

    Find the segment that contains x, then compute y0 + (x - x0) x (y1 - y0) / (x1 - x0). Clamp below the first and above the last breakpoint. For breakpoints x = {0, 100, 200, 400} and y = {0, 50, 80, 200}, x = 150 gives 65 and x = 300 gives 140. Time O(n) linear search or O(log n) with binary search. Common mistake: dividing before multiplying, which truncates the slope to zero in integers.

    c
    #include <stdio.h>
    static const int X[] = {0, 100, 200, 400};
    static const int Y[] = {0, 50, 80, 200};
    int interp(int x) {
        int n = 4;
        if (x <= X[0]) return Y[0];
        if (x >= X[n - 1]) return Y[n - 1];
        int i = 0;
        while (x >= X[i + 1]) i++;
        return Y[i] + (x - X[i]) * (Y[i + 1] - Y[i]) / (X[i + 1] - X[i]);
    }
    int main(void) {
        printf("%d %d %d\n", interp(150), interp(300), interp(-5)); /* 65 140 0 */
        return 0;
    }
  8. 8

    Detect rising and falling edges of a digital input sampled periodically.

    easy

    Keep the previous sample. A rising edge is prev 0 and now 1, a falling edge is prev 1 and now 0. For the samples 0, 0, 1, 1, 0, 1 there are 2 rising and 1 falling edge. Time O(n), state of one bit. Common mistake: initialising prev to 1 and reporting a false falling edge on the first sample if the line was actually low.

    python
    def edges(samples):
        prev, rise, fall = samples[0], 0, 0
        for s in samples[1:]:
            if prev == 0 and s == 1: rise += 1
            if prev == 1 and s == 0: fall += 1
            prev = s
        return rise, fall
    
    print(edges([0, 0, 1, 1, 0, 1]))  # (2, 1)
  9. 9

    Implement a saturating up/down counter that stays within a range.

    medium

    Increment unless at the maximum and decrement unless at the minimum, so the value never wraps. With range 0 to 3, starting at 2 and applying +, +, +, -, the values are 3, 3, 3, 2. This models a debounce or fault-confirmation counter. Time O(1) per event. Common mistake: using an unsigned counter and decrementing below zero, which wraps to a huge value.

    c
    #include <stdio.h>
    int main(void) {
        int cnt = 2, lo = 0, hi = 3;
        const char ev[] = "+++-";
        for (int i = 0; ev[i]; i++) {
            if (ev[i] == '+' && cnt < hi) cnt++;
            else if (ev[i] == '-' && cnt > lo) cnt--;
            printf("%d ", cnt);
        }
        puts("");  /* 3 3 3 2 */
        return 0;
    }
  10. 10

    Compute an XOR checksum over a CAN payload and verify a frame.

    medium

    XOR all data bytes together; XORing the checksum into the same value gives zero for a valid frame. For bytes 0x12, 0x34, 0x56 the checksum is 0x12 ^ 0x34 ^ 0x56 = 0x70. Time O(n), space O(1). An XOR checksum detects any single-bit error but misses two flips in the same bit position of different bytes, so safety-critical messages use a CRC. Common mistake: including the checksum byte in the calculation when generating it.

    c
    #include <stdio.h>
    #include <stdint.h>
    uint8_t xor_sum(const uint8_t *p, int n) {
        uint8_t x = 0;
        while (n--) x ^= *p++;
        return x;
    }
    int main(void) {
        uint8_t f[4] = {0x12, 0x34, 0x56, 0};
        f[3] = xor_sum(f, 3);
        printf("0x%02X %d\n", f[3], xor_sum(f, 4) == 0); /* 0x70 1 */
        return 0;
    }
  11. 11

    Find the second-largest distinct value in an array in one pass.

    medium

    Keep the largest and the second-largest seen so far. For each value greater than the largest, shift the largest down; otherwise, if it is greater than the second and not equal to the largest, replace the second. For [4, 9, 9, 7, 2] the answer is 7. Time O(n), space O(1). Common mistake: returning the repeated maximum as the second value, or sorting for O(n log n) when one pass was asked.

    python
    def second_largest(a):
        first = second = None
        for x in a:
            if first is None or x > first:
                first, second = x, first
            elif x != first and (second is None or x > second):
                second = x
        return second
    
    print(second_largest([4, 9, 9, 7, 2]), second_largest([5, 5]))  # 7 None
  12. 12

    Check for balanced brackets in a configuration string.

    medium

    Push each opening bracket on a stack and, on a closing bracket, pop and check that it matches; the string is balanced if the stack is empty at the end and no pop fails. "{[()]}" is balanced and "([)]" is not. Time O(n), space O(n). Common mistake: popping from an empty stack on an extra closing bracket, so test for emptiness first.

    python
    def balanced(s):
        pairs = {')': '(', ']': '[', '}': '{'}
        st = []
        for ch in s:
            if ch in '([{':
                st.append(ch)
            elif ch in pairs:
                if not st or st.pop() != pairs[ch]:
                    return False
        return not st
    
    print(balanced("{[()]}"), balanced("([)]"), balanced("(()"))  # True False False

Frequently asked questions

What coding questions does a Bosch technical test include?

Bosch does not publish its test content on its programme pages. Commonly reported topics for software and embedded roles are C output prediction, bit manipulation, arrays and strings, plus core subjects of your branch.

Is the test in C or another language?

Embedded and automotive roles expect C, so practise there. Other roles may accept other languages; check your invitation.

Are these real Bosch problems?

No. They are practice problems in the style of topics such tests are commonly reported to cover. The company does not publish its papers.

Where do I check eligibility and openings?

Use Bosch India's own programme pages and your placement office. How to crack the Bosch interview explains the process.

Sources

Related guides

More in Company Interview Questions

See all in this section