CS 56

20240103 C - 연산자

#include int main() { // lhs: Left Hand Side // rhs: Right Hand Side int lhs = 5; int rhs = 2; printf("lhs + rhs: %d\n", lhs + rhs); // -보다 +가 빠름 -연산은 +연산으로 바꿔서 연산 printf("lhs - rhs: %d\n", lhs - rhs); printf("lhs * rhs: %d\n", lhs * rhs); // /보다 *가 빠름 /연산은 *연산으로 바꿔서 연산 printf("lhs / rhs: %d\n", lhs / rhs); printf("lhs %% srhs: %d\n\n", lhs % rhs); printf("1+((3*2)/2.0f) Result: %f\n\n", 1+((3*2..

CS/C 2024.01.03

20240102 C - 데이터 타입

자료형(Data Type) 변수(Variables) 자료형 변수명 = 초기값; 선언: Declaration 이런게 잇다 이런거 쓸거다 선언 정의: Definition 아까 쓸거다 말한 '이런거'의 내용 정의 printf(%d %p, i, &i); int: Integer(정수) 기본 자료형 4byte %d : Decimal 10진수 %p 메모리 주소 16진수 int i = 10; &i 변수의 메모리 주소 8bit - 1byte 8bit 16bit 32bit(4byte) 64bit 등등 cpu가 한번에 처리할 수 있는 양 32bit 코딩이기 때문에 int가 4byte이며 4byte,32bit인 int가 연산이 가장 빠름 float: Floating-point(실수) 부동(浮動)소수점 4byte 8bit 정수..

CS/C 2024.01.02

20231229 C - HelloWorld

#include int main() { printf("Hello, World!\n"); return 0; } # : 전처리기 : 경로 (절대경로) c가 설치되어 있는 그 위치 stdio: Strandard Input/Output .h : Hearder 함수(function) int: 반환형(Return Type) main: 함수명(Function Name) 함수 정의(Function Definition) Method int main(){} : Entry Function C에서 main함수 - int형으로 반환하고, return 0를 표기하는 것이 표준 편의성을 위해 void형 반환과, return 0 을 명시하지 않는 것을 허용함 printf(): 함수호출(Function Call) print Forma..

CS/C 2023.12.29
반응형