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