s inf a’zolariga murojat usullari. Ob’yektlar yaratish va ulardan foydalanishga doir masalalar yechish. Kalit so’zlar




Download 90,96 Kb.
bet4/6
Sana22.02.2024
Hajmi90,96 Kb.
#160738
1   2   3   4   5   6
Bog'liq
1.1amaliy ish

volatile sinfi o’zgaruvchilari. Agar programmada o’zgaruvchini birorta tashqi qurilma yoki boshqa programma bilan bog’lash uchun ishlatish zarur bo’ladigan bo’lsa, u volatile modifikatori bilan e’lon qilinadi. Kompilyator bunday modifikatorli o’zgaruvchini registrga joylashtirishga harakat qilmaydi. Bunday o’zgaruvchilar e’loniga misol quyida keltirilgan:
volatile short port_1;
volatile const int Adress=0x00A2;
Misoldan ko’rinib turibdiki, volatile modifikatorli o’zgarmas ham e’lon qilinishi mumkin.

onsider this sample program: 1int x;


2int mystery(int x)
3{
4 int s = 0;
5 for (int i = 0; i < x; i++)
6 {
7 int x = i + 1;
8 s = s + x;
9 }
10 return x;
11}
12int main()
13{
14 x = 4;
15 int s = mystery(x);
16 cout << s << endl;
17}
28. Which line defines a global variable?
29. Which lines define local variables named x?
30. Which lines are in the scope of the definition of x in line 2?
31. Which variable is changed by the assignment in line 14?
32. This program defines two variables with the same name whose scopes don’t
overlap. What are they?



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 */

Download 90,96 Kb.
1   2   3   4   5   6




Download 90,96 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



s inf a’zolariga murojat usullari. Ob’yektlar yaratish va ulardan foydalanishga doir masalalar yechish. Kalit so’zlar

Download 90,96 Kb.