Microsoft Visual C++/cli step by Step



Download 2,23 Mb.
Pdf ko'rish
bet69/102
Sana31.12.2021
Hajmi2,23 Mb.
#228061
1   ...   65   66   67   68   69   70   71   72   ...   102
Bog'liq
Visual studio C step by step

 

CHAPTER 5

 

Decision and loop statements 



 71

Note The for statement is very flexible. You can omit any of the three expressions in the 

for construct as long as you retain the semicolon separators. You can even omit all three 

expressions, as in for( ; ; ), which represents an infinite loop

The preceding example displays the output shown in the following screen shot.

In this exercise, you will modify your Calendar Assistant application so that it uses a for loop rather 

than a while loop to obtain five dates from the user.

1. 

Continue working with the project from the previous exercise.



2. 

Modify the code in the main function to use a for loop rather than a while loop, as shown 

here:

Console::WriteLine("Welcome to your calendar assistant"); 



 

for (int count = 1; count <= 5; count++) 

    Console::Write("\nPlease enter date "); 



    Console::WriteLine(count); 

 

    int year = GetYear(); 



    int month = GetMonth(); 

    int day = GetDay(year, month); 

    DisplayDate(year, month, day); 

}

Notice that there is no count++ statement after displaying the date. This is because the for 



statement takes care of incrementing the loop counter.

3. 

Build and run the application. The application asks you to enter five dates, as before.




Download 2,23 Mb.

Do'stlaringiz bilan baham:
1   ...   65   66   67   68   69   70   71   72   ...   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