프로그래밍 c 언어

7
IT IT 공공공공공공 공공공공공공 CADBANK CADBANK 공공공공공 공공공공공 C C 공공 공공

Upload: arthur-murray

Post on 30-Dec-2015

50 views

Category:

Documents


0 download

DESCRIPTION

프로그래밍 C 언어. C 의 자료형. C 의 자료형. #include int main() { short books, weight; short total; weight = 30; books = 1500; total = books * weight; printf(" 책 1500 권의 무게는 %d 이다 .\n",total); return 0; }. C 의 자료형. sizeof 연산자 - 단항 연산자 - 할당된 메모리 크기. C 의 자료형. int main() - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

프로그래밍 프로그래밍 C C 언어언어

Page 2: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

자료형자료형 크기크기 (( 바이트바이트 )) 범위범위charchar 11 -128 ~ 127-128 ~ 127

shortshort 22 -32,768 ~ 32,767-32,768 ~ 32,767

int int 44-2,147,483, 648 ~ -2,147,483, 648 ~

2,147,483, 6482,147,483, 648

longlong 44-2,147,483, 648 ~ -2,147,483, 648 ~

2,147,483, 6482,147,483, 648

floatfloat 44-3.4*10^37 ~ -3.4*10^37 ~

3.4*10^383.4*10^38

doubledouble 881.7*10^307 ~ 1.7*10^307 ~ 1.7*10^308 1.7*10^308

long doublelong double 8 8 또는 그 이상또는 그 이상 3.4*10^4931 ~ 3.4*10^4931 ~ 1.1*10^49321.1*10^4932

Page 3: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

#include <stdio.h>#include <stdio.h>

int main()int main()

{{

short books, weight;short books, weight;

short total;short total;

weight = 30;weight = 30;

books = 1500;books = 1500;

total = books * weight;total = books * weight;

printf("printf(" 책 책 15001500 권의 무게는 권의 무게는 %d%d 이다이다 .\n",total);.\n",total);

return 0;return 0;

}}

Page 4: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

sizeof sizeof 연산자연산자

- - 단항 연산자단항 연산자

- - 할당된 메모리 크기할당된 메모리 크기

Page 5: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

int main()int main()

{{

printf("char : %d byte\n",sizeof(char));printf("char : %d byte\n",sizeof(char));

printf("short : %d byte\n",sizeof(short));printf("short : %d byte\n",sizeof(short));

printf("int : %d byte\n",sizeof(int));printf("int : %d byte\n",sizeof(int));

printf("long : %d byte\n",sizeof(long));printf("long : %d byte\n",sizeof(long));

printf("float : %d byte\n",sizeof(float));printf("float : %d byte\n",sizeof(float));

printf("double : %d byte\n",sizeof(double))printf("double : %d byte\n",sizeof(double))

return 0;return 0;

}}

Page 6: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

int main()int main()

{{

float f;float f;

double d;double d;

f = 12345670.12;f = 12345670.12;

d = 12345670.12;d = 12345670.12;

printf("%f\n",f);printf("%f\n",f);

printf("%f\n",d);printf("%f\n",d);

return 0;return 0;

}}

Page 7: 프로그래밍  C  언어

IT IT 공인교육기관 공인교육기관 CADBANKCADBANK

CC 의 자료형의 자료형

자료형자료형 크기크기 (( 바이트바이트 )) 범위범위

unsigned charunsigned char 11 0 ~ (127+128)0 ~ (127+128)

unsigned shortunsigned short 22 0 ~(32,767+32,768)0 ~(32,767+32,768)

unsigned int unsigned int 440 ~(2,147,483, 647+ 0 ~(2,147,483, 647+

2,147,483, 6482,147,483, 648

unsigned longunsigned long 440 ~ (2,147,483, 647+ 0 ~ (2,147,483, 647+

2,147,483, 648)2,147,483, 648)