Object References

Medium References
Solve in Playground →

Problem Statement

Write a C++ program passing a custom `Account` object by reference to update balances.

Input Format

Initial balance and deposit amount.

Output Format

Print updated balance formatted to 2 decimal places.

Constraints

Balances >= 0

Sample Input

1000.0 500.0

Sample Output

1500.00

Explanation

Passes class objects by reference to modify internal state efficiently.

Starter Code

#include <iostream>
#include <iomanip>

class Account {
public:
    double balance;
    Account(double b) : balance(b) {}
};

void deposit(Account &acc, double amt) {
    acc.balance += amt;
}

int main() {
    double b, amt;
    if (std::cin >> b >> amt) {
        Account myAcc(b);
        deposit(myAcc, amt);
        std::cout << std::fixed << std::setprecision(2) << myAcc.balance << "n";
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used