1. Syntax (type-name) expression #include int main() { int math = 90, korean = 95, english = 96; int sum = math + korean + english; double avg = (double)sum / 3; // 정수 / 정수 = 정수 // 실수 / 정수 = 실수 // 실수 / 실수 = 실수 // 정수 + 정수 = 정수 // 정수 + 실수 = 실수 // 실수 + 실수 = 실수 printf("%f\n", avg); // 93.666667 return 0; } Reference: https://en.cppreference.com/w/c/language/cast
1. char 8비트(1바이트) 문자를 담는데 사용 2. short16비트(2바이트) 정수를 담는데 사용 3. int32비트(4바이트) 운영체제의 환경에 따라 사용되는 비트 수가 다름예) 16비트 컴퓨터에서는 16비트로 사용됨정수를 담는데 사용 #include int main() { int ia = 5; int ib = 3; int iSum = ia + ib; int iSubstract = ia - ib; int iMultiply = ia * ib; int iQuotient = ia / ib; int iReminder = ia % ib; printf("%d + %d = %d\n", ia, ib, iSum); printf("%d - %d = %d\n", ia, ib, iSubstract); printf("..
1. Syntax // 한 줄 주석 /* 여러 줄 주석 */코드 실행시 컴파일러가 무시하는 부분으로서 코드 가독성을 늘리기 위해 사용 #include /* C-style comments can contain multiple lines. */ /* Or, just one line. */ // C++-style comments can comment one line. // Or, they can // be strung together. int main(void) { // The below code won't be run // puts("Hello"); // The below code will be run puts("Hello"); } Reference: https://en.cppreference.com/w/c..