8escs01 problem solving through programming unit-2: c programming basics



Download 0,98 Mb.
bet21/22
Sana19.05.2023
Hajmi0,98 Mb.
#940862
1   ...   14   15   16   17   18   19   20   21   22
Bog'liq
Module 2 c program

CONTROL STATEMENTS


LOOPING STATEMENTS – FOR LOOP
  • A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

Syntax:

Flow Diagram:

for ( init; condition; increment )
{
statement(s);
}

89

CONTROL STATEMENTS


void main ()
{
int a;
for( a = 10; a < 20; a = a + 1 )
{
printf("%d", a);
}
}
90
LOOPING STATEMENTS – FOR LOOP
Example:
#include
Output:
10 11 12 13 14 15 16 17 18 19

CONTROL STATEMENTS


LOOPING STATEMENTS – WHILE LOOP
  • A while loop statement repeatedly executes a target statement as long as a given condition is true.
  • Here the condition is checked first, so it is also called as entry control statements

Syntax:

Flow Diagram:

while(condition)
{
statement(s);
}

91

CONTROL STATEMENTS


void main ()
{
int a = 10;
while( a < 20 )
{
printf(" %d", a); a++;
}
}
LOOPING STATEMENTS – WHILE LOOP
Example:
#include
Output:
10 11 12 13 14 15 16 17 18 19

CONTROL STATEMENTS


LOOPING STATEMENTS – DO…WHILE LOOP
  • Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming language checks its condition at the bottom of the loop.
  • A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
  • This is also called exit control statement.


Download 0,98 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   22




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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