C++ Programming Exercise with Solution : Simple bank account program practice

Exercise:
Get money and show balance until user put number <0

Example:
Put money : 400
Your Balance: 400
Put money : 100
Your Balance : 500
Put money : 200
Your Balance : 700
Put money : -1
Deposit completed.

Solution:

#include<iostream>
using namespace std;

int money;

void bAccount(int a){
 static int balance =0; //static mean assign only one time
 balance+=a;
 cout<<"Your balance: "<<balance<<endl;
}

int main(void){

 cout<<"Simple Bank Account."<<endl;
 while(1){
  cout<<"Money to save: ";
  cin>>money;
  if(money<0){
   cout<<"Deposit completed"<<endl;
   break;
  }
  bAccount(money);
 }

 return 0;
}

See also the same exercise with Java Programming.

Feel free to comment below.