2. ¶
- 톡 회 15~16/화 16~17 행
- High-level programming skill low-level HW 하 low-level 하 한(...)
- : : http://cau.ac.kr/~bongbong/c10/
2.1. 1회(2012 - 03 - 27) ¶
-
- C low-level 하 해 폰 키텍
- C UNIX OS 퓨템 해할 판
- 포 scanf & keyword 해 하 함
- binary digit 한 퓨 템 한
- C UNIX OS 퓨템 해할 판
- 해, Compile error, logical error, debug error 해
-
- C
- variable main function 할
- #include header file
- 파 할 compile -> link -> build
2.1.1. : 항 하. ¶
- c
- High-Level Low-Level
- High-Level 해하 (Human Friendly)
- High-Level 해하 (Human Friendly)
- Low-Level 해하 (Machine Friendly)
- High-Level Low-Level
- High-Level Low-Level 환해 할 한
- 퓨 퓨
- , ,
- , ,
- bit
-
- 1bit=0,1 / 2bit=00,01,10,11 / 3bit=000,001,010,011,100 ...
- 1bit=0,1 / 2bit=00,01,10,11 / 3bit=000,001,010,011,100 ...
- 함 (Function) 합
- 하 함 할 헤파 한
- 하 함 할 헤파 한
- (variable)
- int, float, char
- int 할 하 %d
- float 표하 할 하 %f
- char 할 하 %c
- int 할 하 %d
- int: integer type, 4 bytes
- char: It used to express a character, but also used to express a integer. 1 byte
- float: 4 byte, floating type number. Specification in IEEE 754-2008
- function: input -> output
- Main function
- real part of program
- It has start and end point of a program.
- return 0; : 0 is a flag noticing OS that program is ended.
- real part of program
2.2. 2회(2012 - 04 -05) ¶
- : Variables, Data Types, Standard I/O
- Variables
- identifier -> .
- keyword
- overflow
- escape sequence
- identifier -> .
- Data Type
- Integer type: int(4 bytes), char(1 byte, be often used to express a character)
- float type: float, double (double is more correct than float)
- unsigned - MSB 통해 2
- Maximum, minimum value of int( )
- Integer type: int(4 bytes), char(1 byte, be often used to express a character)
- Standard I/O
- format specifications
- printf, scanf
- scanf & 할?
- format specifications
- preprocessor()
- #define
- #define
- automatic type conversion
- Example Problem: Write a program that converts meter-type height into feet(integer),inch(float)-type height. Your program should get one float typed height value as an input and prints integer typed feet value and the rest of the height is represented as inch type. (1m=3.2808ft=39.37inch) (: ppt)
- Variables
2.2.1. ¶
-
- 2, , 해
-
- 1 학 해
- underscore (_) 해 한
- 한
- 파 해 해 (identifier)
- 할
- C 29 키
- 할 큰 한
- 2 (?)
- 한
- 한 행하 한 \ (back slash) 표
- (\n), 탭 (\t), 큰표 (\"), 표 (\'), (\\) .
- int : 4 byte. 표.
- char: 1 byte. 표 (character).
- float, double: 4 byte, 8 byte. 표하
- double float 확하 표할
- float => -1.0E+38 ~ 1.0E+38 / double => -1.0E+308 ~ 1.0E+308
- 1.0E?
- double float 확하 표할
- unsigned ~ : 표함 큰 표할
- 표 / 하 해 0 표하 하 표
- 표 / 하 해 0 표하 하 표
- 2^31-1=???
- (Input) / (Output)
- 헤 파 <stdio.h>
- printf ("", argument);
- scanf("format specifier(s)", &argument);
- format specifications
- - %d (int), %f (float), %c (char)
- - %d (int), %f (float), %c (char)
- scanf & : & 한 하 해 하 할 한
- #define
- 하 한 해 할
#include <stdafx.h> #include <stdio.h> int main () { float meter=0; scanf("%f",&meter); int feet=meter*3.2808; float inch=(((meter*3.2808)-feet)/3.2808)*39.37; printf("%d feet %f inch\n",feet,inch); return 0; }
2.3. 3회 (2012 - 04 -09) ¶
- Operators
- arithmetic operators: binary, unary
- priority
- precedence
- arithmetic operators: binary, unary
- assignment operator
- decrements / increments : postfix / prefix
-
- bitwise operator
- Binary numeral system
- Binary numeral system
- 2's complement: 표
#include<stdio.h> int main() { int input, output; scanf("%d", &input); output = ~input; output ++; printf("%d\n", output); return 0; }
2.3.1. ¶
- 히, ( ?)
- 한 and operator 하 큰 하(scanf, printf )
- shift operator 하 128(=2^5) 하, 128 (variable) 하 left shift operator 하 32 하
- 하
- 1110 0111 ^ 1101 0001 = ?
- 1110 0111 | 1101 0001 = ?
- 1110 0111 ^ 1101 0001 = ?
- Assignment operator
- Equal sign (=) Assignment operator
- 해
- : ->
- Equal sign (=) Assignment operator
- Decrement / Increment : postfix / prefix
- Decrement --, Increment ++
- 1
- Postfix Decrement/Increment operator 하
- Prefix Decrement/Increment operator 하 행하
- Decrement --, Increment ++
- (Shorthand Operators)
- 포함 할
- +=, -=, *=, /=, %=
- Ex. (A = A + B) (A += B ) 표
- Ex. (A = A + B) (A += B ) 표
- 포함 할
- 트 (Bitwise Operators)
- 2 표 Bit 하 표
- 2 (Binary numeral system)
- 1 0 해 .
- 퓨 2 1 true, 0 false
- 2 10 2 2^(n-1) 해
- 10 2 10 2 1, 0
- 2 (Binary numeral system)
- Left shift : a<
- a 트 n , 트 0
- a 트 n , 트 0
- Right shift : a>>n
- a 트 n , 트 0
- a 트 n , 트 0
- And : a & b
- a b 트 하 0, 1 표한
- a b 트 하 0, 1 표한
- Or : a | b
- a b 트 하 하 1 1 표한
- a b 트 하 하 1 1 표한
- XOR : a ^ b
- a b 트 하 1, 0 표한
- a b 트 하 1, 0 표한
- 1's complement : ~a
- a 트 킨 : 1->0, 0->1
- a 트 킨 : 1->0, 0->1
- 2 표 Bit 하 표
- 2's complement
- Bit 표
- A -A , A 트 1's complement 킨 1 해
- A -A , A 트 1's complement 킨 1 해
- Bit 표
#include <stdio.h> int main () { int num ; int temp1 ; printf ("enter a number : "); scanf ("%d", &num); temp1 = num & 1 ; if (temp1 == 1) { printf ("%d\n", num - 1); } else if (temp1 == 0) { printf ("%d\n", num - 2); } return 0; }
#include <stdio.h> int main () { int num = 1 ; num = num<<7; printf ("%d\n", num); int num2 ; num2 = num ; num2 = num2>>2; printf ("%d\n", num2); return 0; }
- 1110 0111 ^ 1101 0001 = 0011 0110
- 1110 0111 | 1101 0001 = 1111 0111