3. Reference Alias Update

#include <iostream>
#include <cstdint>

int main() {
    int32_t a, b;
    std::cin >> a >> b;

    int32_t& ref = a;   // Create reference alias to a
    ref += b;           // Modify a only through the reference

    std::cout << a;
    return 0;
}

Explanation & Logic Summary:

  • int32_t& ref = a; binds ref as an alias to a
  • A reference does not allocate separate storage
  • Any modification through ref directly updates a
  • Adding b via the reference updates the final value of a

Firmware Relevance & Real-World Context:

  • Fixed-width types ensure predictable behavior across architectures
  • References eliminate null-pointer risk
  • Common in configuration structures and driver APIs
  • Zero runtime overhead — resolved entirely at compile time

 

 

 

 

Loading...

Input

5 3

Expected Output

8