C# 0 The Complete Reference


PART I C h a p t e r   5



Download 4,07 Mb.
Pdf ko'rish
bet146/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   142   143   144   145   146   147   148   149   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   5 :  

P r o g r a m   C o n t r o l   S t a t e m e n t s  

93

PART IPART I



continue to execute as long as the condition tests true. Once the condition becomes false, the 

loop will exit, and program execution will resume on the statement following the 



for

.

The



for

 loop can proceed in a positive or negative fashion, and it can change the loop 

control variable by any amount. For example, the following program prints the numbers 

100 to –100, in decrements of 5:

// A negatively running for loop.

using System;

class DecrFor {

  static void Main() {

    int x;

    for(x = 100; x > -100; x -= 5)

      Console.WriteLine(x);

  }


}

An important point about 



for

 loops is that the conditional expression is always tested at 

the top of the loop. This means that the code inside the loop may not be executed at all if the 

condition is false to begin with. Here is an example:

for(count=10; count < 5; count++)

  x += count; // this statement will not execute

This loop will never execute because its control variable, 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   142   143   144   145   146   147   148   149   ...   1096




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