Konstruktorlar va destruktorlar




Download 32.72 Kb.
bet2/2
Sana27.02.2024
Hajmi32.72 Kb.
#163472
1   2
Bog'liq
1.2.1.3- amaliy ish
Документ Microsoft Office Word (2), Talablar, 10 ОП академик лицей, Til-bilgan-el-biladi-tadbir-dasturi, test sinovi, Raximova Roxat Boysoatovna (2), Каким этическим требованиям должен соответствовать судья и какие этические требования играют главную роль при вынесении судебного решения, 1 Bandlik darajasi, JAMIYATNING SIYOSIY HAYOTIDA DAVLATNING O\'RNI VA RO\'LI, FALSAFA TARIXIDA RIVOJLANISH XAQIDAGI QARASHLAR, FALSAFANING FAN VA DUNYOQARASHGA DOIR MAQSADI, CHIZIQLI ALGEBRYA VA ANALITIK GEOMETRIYA ELEMENTLARI, Funksiyalarni Teylor va Makloren qatoriga yoyish., Achilov Shaxzod dars ishlanma, 1.1amaliy ish
ch05/account.cpp
1 #include
2
3using namespace std;
4 5 /**
6Withdraws the amount from the given balance, or withdraws
7a penalty if the balance is insufficient.
8@param balance the balance from which to make the withdrawal 9@param amount the amount to withdraw
10 */
11void withdraw(double& balance, double amount)
12 {
13constdouble PENALTY = 10;
14if (balance >= amount)
15 {
16balance = balance - amount;
17 }
18else
19 {
20balance = balance - PENALTY;
21 }
22 }
23
24int main()
25 {
26double harrys_account = 1000;
27double sallys_account = 500;
28 withdraw(harrys_account, 100);
29// Now harrys_account is 900
30withdraw(harrys_account, 1000); // Insufficient funds
31// Now harrys_account is 890
32 withdraw(sallys_account, 150);
33 cout <<«Harry’s account: «<< harrys_account << endl; 34 cout <<«Sally’s account: «<< sallys_account << endl; 35
36return0;
37 }
program run
Harry’s account: 890 Sally’s account: 350

Download 32.72 Kb.
1   2




Download 32.72 Kb.