auto break case char const ontinue default do














예약어 auto break case char const ontinue default do double else enum extern Float for goto if int Inline long register return short signed sizeof static struct switch typedef union unsigne d void volatile while 14

자료형 C언어에서 제공되는 자료의 형태 q 문자 q n char, unsigned char q 정수 n n short , int , long unsigned short, unsigned int, unsigned long q 실수 n float , double , long double q 논리 n boolean 15




자료형 크기 자료범위 출력 문자 char 1 byte -28 -1 ~ 28 -1 – 1 %c Unsigned char 1 byte 0 ~ 28 -1 %c 19





정수형 자료형 크기 자료범위 출력 문자 short 2 byte -216 -1 ~ 216 -1 -1 %d int 2 or 4 byte -216 ~ 215 – 1 or -232 ~ 231 – 1 %d long 4 byte -232 ~ 231 – 1 %ld unsigned ? byte 0 ~ ? ? ? 24

숫자 변수의 출력 실습 #include <stdio. h> void main(void) { int a = 30, b = 10; <출력결과> 30 + 10 = 40 30 - 10 = 20 30 * 10 = 300 30 / 10 = 3 printf(“%d + %d = %d n”, a, b, (a + b)); printf( ); } 25




실수형 자료형 float double long double 크기 자료범위 출력 문자 4 byte -3. 4*1038 ~ 3. 4*1038 %f %e 8 byte -1. 7*10308 ~ 1. 7*10308 %lf 10 byte -3. 4*104932 ~ 3. 4*104932 %lf 29






실습 문제 #include <stdio. h> main( ) { ( ) ch; ( ) a; ( ) b; #include <stdio. h> main( ) { ( ) a; ( ) b; ( ) c; ch = ‘A’; a = 10; b = 3. 14; printf(“ } a = 10000; b = 65530; c = -900. 345 f ”, ch, a, b); printf(“ ”, a, b, c); } 35
- Slides: 35