Tag: Embedded Interview Questions

  • Don’t Miss These Pointer Questions Master Before Any Interview! (2026)

    Don’t miss these must-know pointer questions for interviews. A simple, friendly guide covering basic to advanced pointers to help you prepare with confidence

    Get interview-ready with this friendly and beginner-focused guide on the most important pointer questions. From simple pointer basics to advanced pointer tricks, everything is explained in an easy and clear way. Perfect for students, freshers, and professionals preparing for C, C++, or embedded interviews boost your confidence, strengthen your core concepts, and stay ahead in any technical round!

    BEGINNER-LEVEL POINTER QUESTIONS

    Basics

    1. What is a pointer in C/C++?
    2. Why do we use pointers?
    3. How do you declare a pointer?
    4. What is the size of a pointer?
    5. What does a NULL pointer mean?
    6. What is a wild pointer?
    7. What is a dangling pointer?
    8. What is pointer initialization?
    9. What is the difference between a pointer and a normal variable?
    10. What is the address-of operator (&)?
    11. What is the dereference operator (*)?
    12. How do you assign an address to a pointer?
    13. Can a pointer store NULL?
    14. What happens if you dereference an uninitialized pointer?
    15. What is a void pointer?
    16. What is the use of void *?
    17. What is the difference between int *p and int* p?
    18. What is const int *p?
    19. What is int *const p?
    20. What is const int *const p?

    INTERMEDIATE-LEVEL POINTER QUESTIONS

    Pointer Arithmetic

    1. What is pointer arithmetic?
    2. Why does pointer arithmetic depend on data type size?
    3. Can we increment/decrement a void pointer?
    4. What happens when you compare two pointers?
    5. What is the difference between p++ and ++*p?
    6. How do you find the difference between two pointers?
    7. What is pointer scaling?

    Function Pointers

    1. What is a function pointer?
    2. How do you declare a function pointer?
    3. Why do we use function pointers?
    4. What is a callback function?
    5. What is typedef for function pointers?
    6. How do you pass a function pointer as a parameter?
    7. How do you return a function pointer from a function?
    8. What is a pointer to member function in C++?

    Pointers & Arrays

    1. What is the relationship between pointers and arrays?
    2. Why does array name act like a pointer?
    3. Why can’t we assign to an array name?
    4. What is the difference between arr and &arr?
    5. What is the difference between arr and arr[0]?
    6. How do you use pointer arithmetic to traverse an array?
    7. What is a pointer to an array (int (*p)[5])?
    8. What is an array of pointers (int* p[5])?
    9. What is the difference between pointer to array and array of pointers?
    10. How do you pass a 2D array to a function using pointers?

    Dynamic Memory

    1. What is dynamic memory allocation?
    2. What is malloc, calloc, realloc, free?
    3. What is memory leak?
    4. How do you avoid memory leaks?
    5. What is a double-free error?
    6. Why must you free allocated memory?
    7. What does malloc return?
    8. Why should you check if malloc returned NULL?
    9. What is segmentation fault in context of pointers?

    ADVANCED-LEVEL POINTER QUESTIONS

    Pointer to Pointer & Multi-Level Pointers

    1. What is a pointer to pointer (int **p)?
    2. Why do we use multiple levels of pointers?
    3. What is triple pointer (int ***p) and where used?
    4. How is pointer-to-pointer used in dynamic 2D arrays?

    Constant Pointers & Qualifiers

    1. What is immutable pointer?
    2. What is mutable pointer?
    3. What is the importance of const with pointers in APIs?

    Memory Alignment & Pointers

    1. What is memory alignment?
    2. What happens when a pointer is misaligned?
    3. What is strict aliasing rule?
    4. Why is pointer aliasing dangerous?

    Function Pointer Tables

    1. What is a function pointer jump table?
    2. How are function pointer tables used in drivers?
    3. Why are function pointers used in State Machines?
    4. How do virtual function tables (vtable) use pointers?

    Pointer Casting

    1. What is pointer typecasting?
    2. Is casting between unrelated pointers safe?
    3. What is reinterpret_cast in C++?
    4. Why is reinterpret_cast dangerous?
    5. What is static_cast?
    6. What is dynamic_cast and when to use?

    Pointers in Embedded / System Programming

    1. What is memory-mapped I/O?
    2. How are pointers used for register access?
    3. Why do embedded systems use volatile with pointers?
    4. What does volatile uint32_t* reg = (uint32_t*)0x40002000; mean?
    5. Why is volatile pointer different from pointer-to-volatile?
    6. Why do we use uintptr_t for pointer-to-integer conversions?
    7. What happens if you access invalid memory in bare-metal?

    Pointers & Data Structures

    1. How are pointers used in linked lists?
    2. How is a node created using pointers?
    3. Why do trees heavily use pointers?
    4. How do double pointers help in inserting nodes?
    5. How do pointers enable dynamic queues?
    6. Why are pointers critical in graph adjacency list?

    Pointer Internals

    1. What is pointer indirection level?
    2. Why does pointer dereferencing take time?
    3. What are near, far, huge pointers (old compilers)?
    4. What is segmentation and offset in pointers?
    5. How do pointers work in 64-bit architecture?
    6. How do pointers behave in big-endian vs little-endian?
    7. Why can void* be assigned to any pointer?
    8. Why can’t you do arithmetic on void* in standard C?

    Special Pointer Concepts

    1. What is a smart pointer?
    2. What is unique_ptr, shared_ptr, weak_ptr?
    3. How do smart pointers prevent memory leaks?
    4. What is custom deleter in smart pointers?

    POINTER CODING EXERCISES

    BEGINNER POINTER CODING EXERCISES

    1. Print address and value using a pointer

    Write a program to:

    • Declare an int variable
    • Store its address in a pointer
    • Print the pointer value and pointed value

    2. Swap two numbers using pointers

    Use pointers to swap two integers without using a third variable.

    3. Add two numbers using pointer variables

    Pass pointer addresses to a function and return the sum.

    4. Find length of a string using pointers

    Implement strlen using only pointer arithmetic.

    5. Copy string using pointers

    Write custom strcpy using pointer-to-pointer increment.

    6. Reverse a string using pointers

    Use two pointers (start, end) to reverse a char array.

    7. Print array elements using pointer arithmetic

    Do not use indexing. Only *(p+i) or *p++.

    8. Find maximum element in array using pointers

    Pass array using pointer and find max using pointer arithmetic.

    9. Count vowels in string using pointer traversal

    Increment pointer to iterate over the string.

    10. Check if the string is palindrome using pointers

    Use two pointers: left and right.

    INTERMEDIATE POINTER CODING EXERCISES

    11. Dynamic array using malloc

    • Ask user for size
    • Allocate memory
    • Fill and print elements

    12. Implement your own strcat using pointers

    Append second string to first using pointer increments.

    13. Implement bubble sort using pointers

    Sort using pointer arithmetic instead of indexing.

    14. Create a function to return pointer to max element

    Return pointer to largest element in an array.

    15. Allocate memory for 2D array using double pointer

    int **arr = malloc(rows * sizeof(int*)) … etc.

    16. Write function to free dynamically allocated 2D array

    Free inner + outer pointers properly.

    17. Create a function pointer for arithmetic operations

    Menu:

    • add
    • sub
    • mul
    • div

    Select using function pointer array.

    18. Use function pointers to implement a state machine

    3 states: INIT → PROCESS → EXIT
    Transitions via function pointer table.

    19. Convert lowercase to uppercase using pointer traversal

    Manipulate ASCII values via pointer.

    20. Implement memory copy function (memcpy)

    Use a pointer-to-pointer loop.

    21. Implement strcmp using pointers

    Return:

    • 0 if equal
    • -1 if first < second
    • 1 if first > second

    22. Pointer to array vs array of pointers

    Write code demonstrating both with outputs.

    23. Passing pointer-to-pointer to modify original pointer

    Function should allocate memory and assign it back to caller.

    24. Detect memory leak using pointers

    Simulate:

    • allocate
    • forget to free
    • show correction

    ADVANCED POINTER CODING EXERCISES

    25. Implement a dynamic linked list (insert/delete/traverse)

    Use pointers heavily:

    • malloc
    • pointer-to-pointer for head

    26. Implement a binary tree using struct pointers

    Include:

    • insert
    • search
    • inorder traversal

    27. Create your own malloc() using static memory array

    Simulate:

    • Memory pool
    • Allocation via pointers

    28. Implement smart pointers in C++ (unique_ptr-like)

    Show:

    • RAII
    • destructor deleting memory

    29. Pointer alignment demonstration

    Write code that prints pointer addresses and checks misalignment.

    30. Implement callback mechanism using function pointers

    User function gets executed through a callback argument.

    31. Implement circular buffer using pointers

    Use:

    • read pointer
    • write pointer
    • modulo arithmetic

    32. Implement your own realloc

    Shrink/expand memory and copy old elements manually.

    33. Implement memory-mapped register access (embedded C)

    Simulate:

    #define REG (*(volatile uint32_t*)0x40020000)
    REG = 0xFF;
    

    34. Demonstrate pointer aliasing problem

    Write code where:

    • two pointers refer to same memory
    • updates cause unexpected behavior

    35. Implement a hash table using pointers

    Use:

    • dynamic arrays
    • linked list chaining
    • pointer-to-pointer for insert

    36. Implement function pointer table for drivers

    Simulate operations struct:

    struct ops { void (*init)(); void (*read)(); void (*write)(); };
    

    37. Demonstrate dangling pointer

    Step:

    • allocate
    • free
    • access again

    Then fix it.

    38. Implement double-pointer dynamic 2D matrix

    Manually allocate:

    • row pointers
    • each row

    Print, free.

    39. Implement triple pointer for 3D array

    Show how int ***p manages a 3D matrix.

    40. Implement pointer-based stack

    Use dynamic memory + pointers for:

    • push
    • pop

    50 Pointer Snippet Questions

    Beginner Pointer Snippets

    1.

    int x = 10;
    int *p = &x;
    printf("%d", *p);
    

    2.

    int x = 5;
    int *p = &x;
    *p = 20;
    printf("%d", x);
    

    3.

    int x = 10;
    int *p = NULL;
    printf("%p", p);
    

    4.

    int x = 10;
    int *p = &x;
    p++;
    printf("%d", *p);
    

    5.

    int arr[] = {10,20,30};
    int *p = arr;
    printf("%d", *(p+1));
    

    6.

    char s[] = "Hello";
    char *p = s;
    printf("%c", *p++);
    

    7.

    int a = 10;
    int b = 20;
    int *p = &a;
    p = &b;
    printf("%d", *p);
    

    8.

    int *p;
    int x = 10;
    *p = x;
    printf("%d", *p);
    

    9.

    int x = 10;
    int *p = &x;
    printf("%p %p", &x, p);
    

    10.

    int x = 10;
    int *p = &x;
    printf("%d", *p+2);
    

    Intermediate Pointer Snippets

    11.

    int x = 5;
    int *p = &x;
    int **pp = &p;
    printf("%d", **pp);
    

    12.

    int arr[] = {1,2,3,4};
    int *p = arr+2;
    printf("%d", p[-1]);
    

    13.

    char *p = "ABC";
    printf("%c", *(p+2));
    

    14.

    int a = 5;
    void *vp = &a;
    printf("%d", *(int*)vp);
    

    15.

    int arr[3] = {10,20,30};
    int (*p)[3] = &arr;
    printf("%d", (*p)[1]);
    

    16.

    int *p = NULL;
    printf("%d", *p);
    

    17.

    int a = 10, b = 20;
    int *p1 = &a, *p2 = &b;
    printf("%d", *p1 + *p2);
    

    18.

    int x = 10;
    int *p = &x;
    printf("%lu", sizeof(p));
    

    19.

    int x = 10;
    int *p = &x;
    int **pp = &p;
    pp++;
    printf("%p", *pp);
    

    20.

    int arr[] = {5, 10, 15};
    int *p = arr;
    printf("%d", ++*p);
    

    Advanced Pointer Snippets

    21.

    char str[] = "ABCDE";
    char *p = str;
    printf("%c", ++*p);
    

    22.

    int a = 10;
    int *p = &a;
    *p = ++a;
    printf("%d", a);
    

    23.

    int a = 10;
    int *p = &a;
    int *q = p;
    *q = 100;
    printf("%d", a);
    

    24.

    int arr[5] = {1,2,3,4,5};
    int *p = arr;
    printf("%d", *(p++) + *(++p));
    

    25.

    int x = 10;
    int *p = &x;
    printf("%d", *p++);
    

    26.

    char *p = "hello";
    p[0] = 'H';
    printf("%s", p);
    

    27.

    int a = 10;
    int *p = &a;
    printf("%d %d", a, *p);
    a = 50;
    printf("%d %d", a, *p);
    

    28.

    int arr[] = {10,20,30,40};
    int *p = arr + 3;
    printf("%d", p[-2]);
    

    29.

    void fun(int *p) { *p = 100; }
    int x = 10;
    fun(&x);
    printf("%d", x);
    

    30.

    int *p = malloc(sizeof(int));
    *p = 20;
    printf("%d", *p);
    free(p);
    printf("%d", *p);
    

    Deep Advanced & Tricky Snippets

    31.

    int a = 10;
    int *p = &a;
    *p = *p + (*p++);  
    printf("%d", a);
    

    32.

    int arr[] = {10,20,30,40};
    int *p = arr;
    printf("%d", *++p + ++*p);
    

    33.

    int x = 0;
    int *p = &x;
    if (p)
        printf("Pointer is not NULL");
    

    34.

    int x = 10;
    int y = 20;
    int *p = &x;
    *p = y;
    printf("%d %d", x, y);
    

    35.

    int x = 5;
    int *p = &x;
    printf("%d", (++*p)++);
    

    36.

    int arr[] = {4,3,2,1};
    int *p = arr;
    printf("%d", *p + *(p+1) + *(p+2));
    

    37.

    int x = 5;
    int *p = &x;
    int **pp = &p;
    **pp = 50;
    printf("%d", x);
    

    38.

    char *s = "HELLO";
    printf("%c", *s + 32);
    

    39.

    int a = 10;
    int *p = &a;
    printf("%d", *p + *(p));
    

    40.

    int x = 10;
    int *p = &x;
    printf("%p %p", p, &p);
    

    Pointer + Function Snippets

    41.

    void fun(int *p) {
        p = NULL;
    }
    int x = 10;
    int *p = &x;
    fun(p);
    printf("%p", p);
    

    42.

    void fun(int **p) {
        *p = NULL;
    }
    int x = 10;
    int *p = &x;
    fun(&p);
    printf("%p", p);
    

    43.

    void fun(int *p) { *p = 200; }
    int a = 10;
    fun(&a);
    printf("%d", a);
    

    44.

    void fun(int *p) { p++; }
    int arr[] = {10,20,30};
    int *p = arr;
    fun(p);
    printf("%d", *p);
    

    45.

    void fun(int p) { p = 100; }
    int x = 10;
    fun(x);
    printf("%d", x);
    

    46.

    int fun() { return 5; }
    int (*fp)() = fun;
    printf("%d", fp());
    

    47.

    int add(int a, int b) { return a+b; }
    int (*fp)(int,int) = add;
    printf("%d", fp(5,6));
    

    48.

    int arr[] = {1,2,3};
    int *p = arr;
    printf("%d", (*p)++);
    

    49.

    int x = 10;
    int *p = &x;
    printf("%d", ++(*p));
    

    50.

    int arr[3] = {1,2,3};
    int *p = arr;
    printf("%d", *p + *(p+2));
    

    When it comes to mastering ESP microcontrollers, developers often struggle to find a single place where everything from basics to advanced real-world projects—is explained clearly.
    That’s why resources like Embedded Prep Master have become extremely valuable for students, embedded engineers, and hobbyists.

    One of the best guides available today is:

    Complete ESP Tutorials (Beginner to Advanced) : ESP32 Tutorials

    This guide is a complete gateway for anyone who wants to learn ESP32, ESP8266, IoT development, sensor interfacing, Wi-Fi programming, and real embedded-system projects.

  • Master 25 OOPs Interview Questions for Embedded Software Engineers (2026)

    25 OOPs Interview Questions : Are you preparing for your next Embedded Software Engineer interview? A strong foundation in Object-Oriented Programming (OOPs) is critical, especially when working in C++ for embedded systems. In this article, we will explore 25 frequently asked OOPs interview questions, each explained in-depth with examples tailored for embedded systems. These questions are crafted to help you crack interviews at companies like Bosch, Continental, KPIT, Qualcomm, and more.

    25 OOPs Interview Questions

    Why OOPs in Embedded Software?

    Object-Oriented Programming helps embedded developers to:

    • Organize complex code
    • Promote reusability and modularity
    • Simplify maintenance and debugging
    • Support real-time performance with modern C++ features

    Top 25 OOPs Interview Questions for Embedded Software Engineers

    1. What is Object-Oriented Programming (OOP)?

    Object-Oriented Programming is a programming paradigm based on the concept of objects. Each object is an instance of a class, which encapsulates data and functions. OOP promotes reusability, modularity, and encapsulation — all essential for embedded systems where code efficiency and scalability matter.

    2. What are the main principles of OOP?

    There are four major principles:

    • Encapsulation: Hides internal details, exposes functionality
    • Abstraction: Shows only essential features
    • Inheritance: Reuses code across similar classes
    • Polymorphism: Allows function overloading and overriding

    3. How is OOP different in embedded systems compared to desktop systems?

    Embedded systems have limited memory and processing power, so OOP features must be used judiciously. For example, virtual functions and dynamic memory allocation can impact performance and are often avoided or replaced with static polymorphism (CRTP).

    4. What is a class and object?

    • Class: A blueprint defining data members and member functions
    • Object: A runtime instance of a class
    class LED {
      int pin;
    public:
      LED(int p): pin(p) {}
      void on() { digitalWrite(pin, HIGH); }
    };
    LED led1(13);
    

    5. What is encapsulation? How is it useful in embedded?

    Encapsulation hides implementation details, making code safer and modular. In embedded systems, it helps to limit direct hardware access and prevent bugs.

    6. Explain access specifiers: public, private, protected

    • public: Accessible from anywhere
    • private: Accessible only within the class
    • protected: Accessible in class and its derived classes

    7. What is constructor and destructor in C++?

    • Constructor: Automatically invoked when an object is created
    • Destructor: Automatically called when object goes out of scope
      Used in embedded for initializing hardware and releasing resources.

    8. What is constructor overloading?

    You can define multiple constructors with different parameters:

    class Timer {
    public:
      Timer() {}
      Timer(int delay) { /* Init with delay */ }
    };
    

    9. What is a copy constructor?

    It creates a copy of an object. Useful in embedded when passing objects by value.

    10. What is inheritance and how is it used?

    Inheritance allows creating new classes from existing ones, improving code reuse.

    class Sensor { /* Base */ };
    class TempSensor: public Sensor { /* Derived */ };
    

    11. What is function overloading vs overriding?

    • Overloading: Same function name, different parameters
    • Overriding: Redefining a base class method in a derived class using virtual

    12. What are virtual functions?

    Used for runtime polymorphism. In embedded systems, they should be used cautiously due to the added vtable overhead.

    13. What is pure virtual function and abstract class?

    A pure virtual function makes a class abstract. It’s used to enforce interfaces.

    class Interface {
    public:
      virtual void init() = 0;
    };
    

    14. What is static polymorphism?

    Also known as compile-time polymorphism, achieved using templates or function overloading. Preferred in embedded to avoid runtime overhead.

    15. What are friend functions and classes?

    They bypass encapsulation. Use only when needed in embedded code to access private data (e.g., during low-level hardware debugging).

    16. What is the ‘this’ pointer?

    Points to the current object. Used for object chaining or distinguishing between member and local variables.

    17. What are static data members and static functions?

    • Shared across all objects
    • Useful in embedded for tracking hardware state or shared resources

    18. What is the difference between composition and inheritance?

    • Inheritance: “is-a” relationship
    • Composition: “has-a” relationship

    Prefer composition in embedded to keep class hierarchy shallow and manageable.

    19. What is multiple inheritance and why is it risky?

    A class inherits from more than one base class. Risky in embedded due to ambiguity and complexity. Use interfaces or composition instead.

    20. What is object slicing?

    Occurs when an object of a derived class is assigned to a base class object, losing the derived part. Avoid this in embedded systems by using pointers or references.

    21. What is the role of constructors in embedded hardware abstraction?

    Constructors are used to initialize hardware resources, such as pins, registers, or peripherals, when objects are created.

    22. How do you implement state machines using OOPs in embedded systems?

    Using inheritance and polymorphism, each state can be a class, and transitions can be managed via function calls — clean and scalable.

    23. What is CRTP (Curiously Recurring Template Pattern)?

    Used in embedded systems for static polymorphism without runtime cost.

    template<typename Derived>
    class Base {
      void doSomething() {
        static_cast<Derived*>(this)->impl();
      }
    };
    

    24. How does OOP help in hardware abstraction?

    You can abstract hardware modules (UART, SPI, ADC) as classes with clean interfaces. This decouples application logic from hardware-specific code.

    25. What OOP features should be avoided or used carefully in embedded C++?

    Avoid:

    • Heap allocation (new, delete)
    • Virtual functions in performance-critical paths
    • RTTI and exceptions (not always supported in embedded toolchains)

    Final Thoughts

    Understanding OOPs concepts in C++ for embedded systems is vital to writing clean, maintainable, and scalable code. While embedded software places some constraints on typical OOP usage, modern C++ (especially C++17 and C++20) enables powerful yet efficient patterns suitable for real-time applications.

    If you are preparing for an embedded systems interview, these 25 OOPs interview questions will strengthen your understanding and help you ace your technical rounds.

    Master 25 OOPs Interview Questions for Embedded Software Engineers
    Master 25 OOPs Interview Questions for Embedded Software Engineers (2025)