áѺԴͧ


õ駪͵
ҧõ駪͵
Դͧҫ
ٻẺûСȵҫ
ͧ¡ôԹҫ
ͧ¡äӹdzҧԵʵ
ͧºº
ͧ·ҧáʵ
¹Ծҫ
ӴѺӤѭͧͧ
Ẻ֡Ѵ ͧ " ͧСäӹdz"

( Variables )
ä ͷ˹㹡红
õ駪͵
ҫաõ駪Ѻ ѧ仹
1. ͷ駨еͧӡѺʧǹ ( reserved word ) ҫ

asm

do

huge

short

void

auto

double

if

signed

volatile

break

else

int

sizeof

while

case

enum

interrupt

static

_ds

cdecl

extern

long

struct

_es

char

far

near

switch

_ss

const

float

pascal

typedef

continue

for

register

union

default

goto

return

unsigned

2. ͵ҧ 繵ѡþ˭Ѻѡ 繤еǡѹ TEST , Test , test , tEsT 繤Ъ͡ѹ
3. ͨеͧ鹵鹴µѡͧ underscore ( _ ) ҹ Т鹵鹴µŢ 㹪öСͺµѡ ͧ underscore ͵Ţ TEST_VALUE , HELLO123 , h1_t2 , _username 繵
4. õ駪ͨä
5. õ駪ͨлСͺѡо $ , @ , # , &

ҧõ駪ͷ١ͧ ١ͧ

ͷ١ͧ

 

ͷ١ͧ

A

 

$hello

Ъѡоɤ $

b1

 

User name

Ъժͧҧ

app_passwd

 

3people

Ъ͢鹵鹴µŢ

_testValue

 

while

ЪͫӡѺʧǹҫ

TRUE

 

data%type

Ъѡоɤ %

ҧʴԴͧҫ

ٻẺûСȵҫ
ҧâҹ¡ ûСȵ ( Variable Declaration ) ¹١ͧٻẺûСȵ ʴѧ

type name;

type : Դͧ

name : ͧ͢ 觵ͧ١ͧѡâͧҫ

¹ͻСȵ ǹ˭Ǩ¹ǹǢͧ͹ѧѹ main() 觡¹㹵˹觴ѧ зҹö¡ҡ㴡 ѧʴҧ仹

 

ͧСäӹdz

ͧ¡ôԹҫ
ôԹ㹡¹ҫ 3 äӹdzҧԵʵ ôԹ÷ҧáʵ Сºº 觡ôԹлͧ·ͧ¹ѺôԹû

ͧ¡äӹdzҧԵʵ

ͧ

ôԹ

ҧҹ

+

ǡ

z = x + y

ǡ㹵 x Ѻ㹵 y Ѿ z

-

ź

z = x y

ź㹵 x ¤㹵 y Ѿ z

*

ٳ

z = x * y

ٳ㹵 x ¤㹵 y Ѿ z

/

z = x / y

ä㹵 x ¤㹵 y Ѿ z

%

( modulo )

z = x % y

ä㹵 x ¤㹵 y Ѿɷҡ z

++

 

ҷ˹
( increment )

 

z = ++x

ǡ㹵 x 1 ͹С˹Ѻ z

z = x ++

˹Ңͧ x Ѻ z ͹Ңͧ x ա 1

--

 

Ŵҷ˹ (decrement )

 

z = --x

ź㹵 x Ŵŧ 1 ͹С˹Ѻ z

z = x --

˹Ңͧ x Ѻ z ͹ŴҢͧ x Ŵա 1

+ =

ǡẺŴٻ

z += x

ǡ㹵 x ѺҢͧ z Ѿ˹Ѻ z դ͹Ѻ z = z + x

-=

źẺŴٻ

z -= x

ź㹵 z ¤Ңͧ x Ѿ˹Ѻ z դ͹Ѻ z = z - x

*=

ٳẺŴٻ

z *= x

ٳ㹵 z ѺҢͧ x Ѿ˹Ѻ z դ͹Ѻ z = z * x

/=

ẺŴٻ

z /= x

ä㹵 z ¤Ңͧ x Ѿ˹Ѻ z դ͹Ѻ z = z / x

%=

ẺŴٻ

z %= x

ä㹵 z ¤Ңͧ x Ѿɷҡ ˹Ѻ z դ͹Ѻ
z = z % x

ͧºº
¹ҫ աôԹºº¤ ੾Сºº͡˹͹Ѻ if while 繵 ͧ·Թººҫ ʴѧҧ仹

ͧ

ôԹ

ҧҹ

= =

ҡѺ

x = = y

ҤҢͧ x ҡѺҢͧ y Ѿ͡繨ԧ

!=

ҡѺ

x != y

ҤҢͧ x ҡѺҢͧ y Ѿ͡繨ԧ

<  

¡

x < y

ҤҢͧ x ¡ҤҢͧ y Ѿ͡繨ԧ

<=

¡ҡѺ

x <= y

ҤҢͧ x ¡ҡѺҢͧ y Ѿ͡繨ԧ

>  

ҡ

x > y

ҤҢͧ x ҡҤҢͧ y Ѿ͡繨ԧ

>=

ҡҡѺ

x > = y

ҤҢͧ x ҡҡѺҢͧ y Ѿ͡繨ԧ

ͧ·ҧáʵ
ôԹ÷ҧáʵ繡ҼѾѡҧáʵ ǹ˭ѡѹк кǡѺǧ俿 ͧ·ҧáʵ㹡¹ҫ 3 Դ &&(and) , || (or) ! (not) ѾҡôԹ÷ҧáʵͧ· 3 Դ ʴѧҧ仹 ¡˹ T ᷹ҷ繨ԧ ǹ F ᷹ҷ

x

y

x && y

x || y

!x

T

T

T

T

F

T

F

F

T

F

F

T

F

T

T

F

F

F

F

T

¹Ծҫ
Ծҫ ùӢеҫҴԹôͧ·ҧԵʵ áʵ ͧººҫ 繵觧ҹ ѧʴҧ仹

ӴѺӤѭͧͧ
ǹ˭Ծ¹ѡդѺ͹ աôԹҧл㹹Ծǡѹ 觼Ѿ͡ҧù ͧԨóҨҡӴѺӤѭ͹ѧͧͧ·ҫա˹ ѧʴ㹵ҧ仹

ҧôԹõӴѺӤѭͧͧ ʴѧ仹

 

Ẻ֡Ѵ ͧ ͧСäӹdz

1. 㹢繪ͧ͢ҫ
          1) 3Hello           2) Hello           3) Hello_world           4) Float
2. ͡ӹǹ˹¤ӷͧ ͻСȵ繪Դҧ ѧ仹
          1) char . Ե
          2) int . Ե
          3) float.. 亵
          4) double 亵
          5) long .. Ե
          6) long double. Ե
3. ҡûСȵþѺ˹Ҵѧʴ仹 㴶١Т㴼Դ͡ǹԴҴ
          1) int a;
          2) int b
          3) int Com Budget = 30000;
          4) int Com_Budget = 35000;
          5) int main = 10;
          6) int _count = 451;
          7) int Gibson = 25,000;
          8) char j = Hello;
          9) char j = A';
          10) float x = 45.067;
4. кҡõ駪͵㹢͵仹 㴶١ͼԴ͡˵ؼŻСͺ
          1) void
          2) MAX_ENTRY
          3) double
          4) time
          5) G
          6) Sue's
          7) return
          8) printf
          9) char
          10) #insert
5. ҵͧ红ŵ仹 èлСȵêԴ ʴ觻Сȵô
          1) ӹǹѡ¹ͧ¹
          2) ôͧѡ¹ (0 - 4)
          3) ṹ¢ͧѡ¹
6. ҡ觴ҹҧ z դ
          int x , float y = 6.0 , z;
          x = 5.7; z = x + y;
          1) 11.7                          2) 12                               3) 11                                 4) 12.7
7. ⨷ 3+2/9-(24+3)*10 лżͧ㴡͹
          1) ͧ +            2) ͧ /                3) ͧ ( )               4) ͧ *
8. ١ͧ ͻСȵôѧ
          int a, b, c, d;
          float x;
            b = 22; c = 5; a = b/c; d = b*c; x = b/c
          1) a դҡѺ 4           2) x դҡѺ 4.4           3) d դҡѺ 110           4) x դҡѺ 4.0
9. ҡ÷ҧԵʵ仹 4+6*4/12-1+7 ҴԹõӴѺӤѭͧͧҫըѾ͡
          1) 10                             2) 12.18                           3) 10.3                              4) 12
10. 繤ӵͺ١ͧͧԾ仹 (5 %2) + (7%4) % 10
          1) 4                               2) 5                                  3) 6                                   4) 7

 

 ********************