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



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

Syntax:

Flow Diagram:

do
{
statement(s);
}while( condition );

CONTROL STATEMENTS


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

CONTROL STATEMENTS


LOOPING STATEMENTS – BREAK LOOP
  • The break statement has the following two usages:
  • When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop.
  • It can be used to terminate a case in the switch statement

Syntax:

Flow Diagram:

break;

CONTROL STATEMENTS


void main ()
{
int a = 10; while( a < 20 )
{
printf("%d", a); a++;
if( a > 15)
{
break;
}
}
}
96
LOOPING STATEMENTS – BREAK LOOP
Example:
#include
Output:
10 11 12 13 14 15

CONTROL STATEMENTS


97
LOOPING STATEMENTS – CONTINUE LOOP
  • The continue statement works somewhat like the break statement.
  • Instead of forcing termination of loop, however, continue forces the next iteration of the loop to take place, skipping any code in between.

Syntax:

Flow Diagram:

continue;

CONTROL STATEMENTS


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

CONTROL STATEMENTS


language provides an
unconditional jump from the goto to a labeled statement in the same function.
99
LOOPING STATEMENTS – GOTO LOOP
  • A goto statement in C programming

Syntax:

Flow Diagram:

goto label;
….
….
label: statement;

CONTROL STATEMENTS


void main()
{
int a = 10; LOOP: do
{
if( a == 15)
{
a = a + 1; goto LOOP;
}
printf(" %d", a); a++;
}while( a < 20 );
}
100
LOOPING STATEMENTS – GOTO LOOP
Example:
#include
Output:
10 11 12 13 14 16 17 18 19
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 ©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