** çҹ繤Դ繢ͧ¹ͧ 觼ҹ繵ͧ繴令Ѻ
ҡ բʹ ;ͤ ԡ سѧ¹¤Ѻ ӡ䢢
١ͧ Ѻ
Ѻ˹ѡ
 

C ͹ ͹

㹺͹СǶ֧͹䢡ѹѺ 觡觹繡觷㹡¹ҡ ·仢ͧ¹ѡҧѡ͹㹡õѴԹ㨷 Դô¹ 繵
if
if 繤㹡͹䢷 if Ҕ Ҩӹ㹡õѴԹ
š¹դҡ 80 ô A
š¹ҧ 70-79 ô B 繵
ٻẺ
if ( condition)
{
Statements ;
}
·
condition ͹㹡õǨͺ
Statements ش觷ӧҹ͹繨ԧ

ö¹Ἱԡ÷ӧҹѧ


Ἱԡ÷ӧҹ


ҧ code
С˹ a = 5 ʴѾѧ
a = 5 ԧ ͤ YES
a != 5 ͤ NO


Ѿ YES


ҡ¹ a 繤蹫ҡѺ 5 Ѿ NO


Ѿ YES


if.else
觹ٻẺҹẺǡѺ if else ͡˹÷ӧҹ͹稴
ٻẺ
if ( condition)
{
Statements1;
}
elas
{
Statements2;
}

condition ͹㹡õǨͺ
Statements1 ش觷ӧҹ͹繨ԧ
Statements2 ش觷ӧҹ͹
ö¹Ἱԡ÷ӧҹѧ


Ἱԡ÷ӧҹ


ҧ code
С˹ a = 5 ʴѾѧ
a = 5 ԧ ͤ YES
a != 5 ͤ NO


ŷ͹繨ԧ



ŷ͹


if.else if
觹㹡óշաë͹͹ ٻẺҹẺǡѹѺ if..else
ٻẺ
if (condition 1)
{
Statements 1
}
elas if (condition 2)
{
Statements 2
}
elas if (condition ..n)
{
Statements..n
}
Else
{
Statements ( çѺ͹)
}
condition ͹㹡õǨͺ
Statements ش觷ӧҹ͹繨ԧ
ö¹Ἱԡ÷ӧҹѧ


Ἱԡ÷ӧҹ

ҧ code ͧ¹ͧФѺ ( 繡úҹ)
switch case
觹ٻẺҹẺǡѺ if..else ͹ҡ 2 ҧ͡ ö͹Ẻ ҡ (>) ¡ (<)
ٻẺ
switch (condition)
{
case constant 1:
Statements 1;
break;
case constant 2:
Statements 2;
break;
- - -
case constant N:
Statements N;
break;
default :
}

condition ͹㹡õǨͺ
constant Ҥ㹡õǨͺ͹
Statements ش觷ӧҹ͹䢹繨ԧ
Code ҧ
С˹Ѻ a С˹͹䢡÷ӧҹͤҵ¹


ŷ͵ a = 1



ŷ͵ a = 2



ŷ͵ a >3


ҡش͹䢹鹨դӤѭ㹡¹еͧ͡ش١ͧѺ¹¤Ѻ ö֡ǹͧ¹ ⨷ѭ 觨¹㹺 Ѻ


¹ 20 .. 2554