Microsoft Visual C++/cli step by Step


   Microsoft Visual C++/CLI Step by Step



Download 2,23 Mb.
Pdf ko'rish
bet59/102
Sana31.12.2021
Hajmi2,23 Mb.
#228061
1   ...   55   56   57   58   59   60   61   62   ...   102
Bog'liq
Visual studio C step by step

64  

Microsoft Visual C++/CLI Step by Step

5. 

Run the application again. Type the year 2012 and the month 2.

The application prompts you to enter a day between 1 and 28, as shown here:

6. 

Type a valid day and close the console window when the date is displayed. (Don’t worry about 

the date validation in main: You will remove it later and replace it with more comprehensive 

validation in the GetMonth and GetDay functions.)



performing nested tests

It is possible to nest tests within one another. This makes it possible for you to perform more complex 

logical operations. The following code shows how to use nested tests to accommodate leap years cor-

rectly in the Calendar Assistant application:

int maxDay; 

if (month == 4 || month == 6 || month == 9 || month == 11) 

    maxDay = 30; 



else if (month == 2) 

    bool isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 



    if (isLeapYear) 

    { 


        maxDay = 29; 

    } 


    else 

    { 


        maxDay = 28; 

    } 


else 


    maxDay = 31; 

}

If the month is February, you define a bool variable to determine if the year is a leap year. A year 



is a leap year if it is evenly divisible by 4 but not evenly divisible by 100 (except years that are evenly 

divisible by 400, which are leap years). The following table shows some examples of leap years and 

non–leap years.




Download 2,23 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   102




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish