Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a class to represent a bank account with methods to deposit, withdraw, and check balance.

Hard

Problem Statement

Implement a class to represent a bank account with methods to deposit, withdraw, and check balance.

Sample Input

BankAccount account(100); account.deposit(50); account.withdraw(30);

Sample Output

Current balance: 120

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> class BankAccount { private: double balance; public: BankAccount(double initialBalance); void deposit(double amount); void withdraw(double amount); double getBalance(); }; int main() { // Logic to demonstrate BankAccount functionality return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
BankAccount account(100); account.deposit(50); account.withdraw(30);
Expected Output
Current balance: 120