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


BRANCHING STATEMENTS – NESTED IF STATEMENT



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

84
BRANCHING STATEMENTS – NESTED IF STATEMENT
Example:
#include
Output:
Value of a is 100 and b is 200 Exact value of a is : 100 Exact value of b is : 200

CONTROL STATEMENTS


85
BRANCHING STATEMENTS – SWITCH STATEMENT
  • Switch statements is a multiway branching statements based on the value of an expression
  • The control is transferred to one of the many possible points
  • If no match is there, then the default block is executed
  • Every case statements should be terminated with a break statements

Syntax:

Flow Diagram:

switch (expression)
{
case label1:
statements; break; case label2:
statements; break; default:
statements;
}

CONTROL STATEMENTS


Example: #include void main ()
{ char grade = 'B';
switch(grade)
{ case 'A' : printf("Excellent!\n" );
case 'B' : printf(“Good!\n" );
case 'C' : printf("Well done\n" );
case 'D' : printf("You passed\n" );
break; break; break; break;
case 'F' : printf("Better try again\n" ); break; default : printf("Invalid grade\n" );
}
printf("Your grade is %c\n", grade );
}
86
BRANCHING STATEMENTS – SWITCH STATEMENT
Output:
Good
Your grade is B

LOOPING STATEMENTS

CONTROL STATEMENTS


88
LOOPING STATEMENTS
  • Loop control statements in C are used to perform looping operations until the given condition is true.
  • Control comes out of the loop statements once condition becomes false.
  • There are 3 types:
    • for loop
    • while loop
    • do while loop
    • break
    • continue
    • goto

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