-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpracticep21.cpp
More file actions
36 lines (34 loc) · 850 Bytes
/
practicep21.cpp
File metadata and controls
36 lines (34 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
using namespace std;
union accountdata{
struct{
char name[10];
int accno;
double balance;
}dat;
};
int main(){
accountdata ac;
cout << "Enter Name: ";
cin.getline(ac.dat.name, 10);
cout << "Enter Account Number: ";
cin >> ac.dat.accno;
cout << "Enter Balance: ";
cin >> ac.dat.balance;
cout<<"amount to be added: ";
int addmoney;
cin>>addmoney;
ac.dat.balance+=addmoney;
cout << "Updated Balance: " << ac.dat.balance << endl;
cout<<"amount to be withdrawn: ";
int withdrawmoney;
cin>>withdrawmoney;
if(withdrawmoney<=ac.dat.balance)
ac.dat.balance-=withdrawmoney;
else{
cout<<"Insufficient balance"<<endl;
cout << "Updated Balance: " << ac.dat.balance << endl;
}
return 0;
}