본문 바로가기
[IT] C언어 입문(9) Array와 Pointers, 배열과 포인터 □ Arrays and Pointers(배열과 포인터) * Array(배열) - A collection of identically typed data items distinguished by their indices (or subscripts) - One dimensional arrays : type identifier[size]; - lower_bound = 0, upper bound = size - 1 - ex) int a[10]; * Array Initialization - one_dimentional_array_initializer ::= { initializer_list } - initializer_list ::= initializer { , initializer }* - initializer .. 2021. 8. 28.
[IT] C언어 입문(8) Scope rules/recursion, 변수의 영역규칙과 재귀호출, 난수생성 예시 □ scope rules/recursion * Call by Value Revisited - 함수를 사용하기 위해 미리 선언해두는 것 - 함수의 이름, 변수 타입 int sum(int n); { int s=0 for( ; n>0; n--) s += n; return s; } // 1부터 n까지의 값을 모두 더함 #include int sum(int m); // 함수를 사용하기 위해 미리 함수명과 타입을 선언 int main(void) { intn=5; printf("sum= %d\n", sum(n)); // n이라는 변수가 넘어가는 것이 아닌, 5라는 값(value)가 함수로 넘어감 printf("n=%d\n",n); return 0; } - 참고 : for(;;) => 무한루프 * Large Progr.. 2021. 8. 26.
[IT] C언어 입문(7) Function, 함수 - Goto문, getchar와 putchar, 함수 정의와 프로토타입 선언 □ function, 함수 * Conditional Operator, 조건연산자 - conditional_expression ::= expr ? expr : expr 1. The first expr is evaluated 2. If it is nonzero, then the second expr is evaluated. Otherwise the third expr is evaluated 3. The value and the type of the conditional expression as a whole are the value and the type of the second or third expr evaluated - example x = ( y if ( y < z ).. 2021. 8. 25.
[IT] C언어 입문(6) Control flow, 제어흐름 - While문, For문, If문, do-while문 등 루프문 □ flow of control (control flow) * While Statement - while_statement ::= while (expr) statement 1. expr is evaluated 2. if it is nonzero(true), then statement is executed 3. Control is passed back to the beginning of the while statement - 'while' statement is executed repeatedly until expr is zero - example int i = 1, f = 1, n = 10; while(i i가 10이 될 때까지, 9번 루프 반복, f는 팩토리얼의 값을 나타냄, 9! * For State.. 2021. 8. 24.
[IT] C언어 입문(5) Operators, 연산자 - 논리연산자, 단축평가, 대입연산자, if문 및 while문 활용 □ 연산자 * Logical Operators - !, ||, && - logical_expression ::= logical_negation_expr | logical_or_expr | logical_and_expr - logical_negation_expr ::= !expr (not) - logical_or_expr ::= expr || expr (or) - logical_and_expr ::= expr && expr (and) - The result is 0 or 1 (int) - ex) (804; // b=00000000 - shift operator는 2, 4, 8, 16 ... 을 곱하는 효과가 있음 * Compound assignment operators - " +=, -=, *=, /=, .. 2021. 8. 22.