Presentation is loading. Please wait.

Presentation is loading. Please wait.

The fundamental data type 제 4 주 강의. Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in.

Similar presentations


Presentation on theme: "The fundamental data type 제 4 주 강의. Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in."— Presentation transcript:

1 The fundamental data type 제 4 주 강의

2 Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in memory by a compiler  deciding appropriate operations  checking invalid operations and operands (686page 참고 )

3 Expressions Meaningful combinations of constants, variables, operators, and function calls a+b 5.0*x – tan(9.0/x) Page 689 참고

4 Assignments variable = expr ; Page 689 참고 숙제 ::: a=b=c+d=e  이것이 정상적인 assignment statement 임을 문법을 참고로 증명하라 !!! 적용된 문법을 보일 것

5 The fundamental data types Declaration ::= type identifier {, identifier} 0+ ;

6 Long form Fundamental data types: long form char signed char unsigned char signed short int signed int signed long unsigned short int unsigned int unsigned long float double long double fundamental types array, pointer, structure ::: derived types

7 Widely used form Fundamental data types: long form char signed char unsigned char short int long unsigned short unsigned unsigned long float double long double ‘ int ’ can be omitted

8 Functionality Fundamental types grouped by functionality Integral types Char signed char unsigned char Short int long Unsigned short unsigned unsigned long Floating types Float double long double Arithmetic types Integral types + Floating types

9 3.3 Characters and the Data Type char getchar(), putchar() 8bits (2 8 =256) 대문자, 소문자, 숫자, 구두점, 특수문자 White space characters 는 포함 제어문자는 제외 ASCII, EBCDIC

10 ASCII Some character constants and their corresponding integer values Character constants Corresponding values Character constants Corresponding values Character constants Corresponding values Character constants Corresponding values ‘ a ’ ‘ b ’ ‘ c ’ … ‘ z ’ 9798 99 … 112 ‘ A ’ ‘ B ’ ‘ C ’ … ‘ Z ’ 6566 67 … 90 ‘ 0 ’ ‘ 1 ’ ‘ 2 ’ … ‘ 9 ’ 4849 50 … 57 ‘ & ’ ‘ * ’ ‘ + ’ 38 42 43

11 Special characters Special Characters Name of characterWritten in CInteger value Alert Backslash Backspace Carriage return Double quote Formfeed Horizontal tab Newline Null character Single quote Vertical tab Question mark \a \\ \b \r \ ” \f \t \n \0 \ ’ \v \? 7 92 8 13 34 12 9 10 0 39 11 63

12 출력 printf( “ %c ”, ‘ \a ’ ) ;  putchar( ‘ \a ’ ) printf( “ %\ ” abc\ ”” ) ;  “ abc ” printf( “ %cabc%c ”, ‘ \ ’’, ’ \ ’’ ) ;  ‘ abc ’

13 출력 예 int c; int i; for (i= ‘ a ’ ; i<= ‘ z ’ ;++i) printf( “ %c ”,i); /* abc … z */ for (c=65; c<=90;++c) printf( “ %c ”,c); /* ABC … Z */ for (c= ‘ 0 ’ ; c<= ‘ 9 ’ ;++c) printf( “ %d ”,c); /* 48 49 … 57 */ 01100001(2) == 97 == ‘ a ’

14 Integer 32bits : -2 31, -2 31 +1 … -1, 0, 1, … … 2 31 -1 16bits : -2 15, -2 15 +1 … -1, 0, 1, … … 2 15 -1 N min_int ≤ i ≤ N max_int

15 Short, long, unsigned short  16bits long  32bits unsigned  32bits 기계 : N max_unsigned = 2 32 -1 ( 일부시스템 ) 16bits 기계 : N max_unsigned = 2 16 – 1 ( 일부시스템 ) = 65535  16bits 기계  32000(short), 33000(long)

16 상수표현 방법 Combining long and unsigned SuffixTypeExample u or Uunsigned37U l or Llong37L ul or ULunsigned37UL

17 The floating types Float, double, long double Combining float and unsigned SuffixTypeExample f or Ffloat3.7F l or Llong double3.7L

18 Floating point 값의 표현 Precision, range float  0.d 1 d 2 … d 6 x 10 n (-38 ≤ n≤ 38) double  0.d 1 d 2 … d 15 x 10 n (-308 ≤ n≤ 308) 123.45123451234512345  0.123451234512345 x 10 +3 ( 유효숫자 15) long double  long 으로 구현

19 The use of typedef typedef char uppercase typedef int INCHES, FEET; typedef unsigned long size_t; uppercase u; INCHES length, width;

20 The sizeof Operator sizeof(object) sizeof(char)  1 sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) sizeof(signed) = sizeof(unsigned) = sizeof(int) sizeof(float) ≤ sizeof(double) ≤ sizeof(long double)


Download ppt "The fundamental data type 제 4 주 강의. Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in."

Similar presentations


Ads by Google