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



Download 0,98 Mb.
bet19/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:

if(Condition1)
{
Statements 1;
}
else if(Condition 2)
{
Statements 2;
}
else if(Condition 3)
{
Statements 3;
}
else
{
else statements;
}

CONTROL STATEMENTS


void main ()
{ int a = 100;
if( a == 10 )
{ printf("Value of a is 10\n" ); }
else if( a == 20 )
{ printf("Value of a is 20\n" ); }
else if( a == 30 )
{ printf("Value of a is 30\n" ); }
else
{ printf("None of the values is matching\n" ); } printf("Exact value of a is: %d\n", a );
}
82
BRANCHING STATEMENTS – ELSE..IF STATEMENT
Example:
#include
Output:
None of the values is matching Exact value of a is: 100

CONTROL STATEMENTS


83
BRANCHING STATEMENTS – NESTED IF STATEMENT
  • An if .. else statement is placed inside another if..else statements, this is known as nested if..else statements.
  • These are used when series of decisions are involved.

Syntax:

Flow Diagram:

if( Condition 1)
{
/* Executes when the condition 1 is true */ if(Condition 2)
{
/* Executes when the condition 2 is true */
}
}
else
{
/* Executes

CONTROL STATEMENTS


void main ()
{
int a = 100;
int b = 200;
if( a == 100 )
{
if( b == 200 )
{
printf("Value of a is 100 and b is 200\n" );
}
}
printf("Exact value of a is : %d\n", a ); printf("Exact value of b is : %d\n", b );
}

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