C++

Conditional Operator๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. variable = (cond_expr) ? expr1 : expr2 ๋‹ค์Œ์€ ์˜ˆ์‹œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค. #include using namespace std; int main(){ int a{10}, b{20}; int score {92}; int result {}; // a > b ์ด๋ฉด result = a, b > a ์ด๋ฉด result = b result = (a > b) ? a : b; // score > 90 ์ด๋ฉด Excellent! ์ถœ๋ ฅ // score b) ? a : b; ๋Š” ๋‹ค์Œ๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค if (a > b) { result = a; }else{ result = b; } ์—ฌ๋Ÿฌ ์ค„์˜ if-else๋ฌธ์„ ํ•œ์ค„๋กœ ์น˜ํ™˜ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—,..
ยทC++/๊ธฐํƒ€
lhs op= rhs ์˜ ๋ฐฉ์‹์œผ๋กœ ์ž‘๋™ํ•œ๋‹ค. ex) cost += item * tax // cost = cost + (item * tax)
ยทC++/๊ธฐํƒ€
C++์—์„œ boolean๊ฐ’์„ ๊ธฐ๋ณธ์ ์œผ๋กœ 1 for true, 0 for false๋กœ ์ถœ๋ ฅ๋œ๋‹ค. ํ•˜์ง€๋งŒ, true/false๋กœ ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์ด ๋”์šฑ ์œ ์šฉํ•œ ๊ฒฝ์šฐ๋„ ๋งŽ๋‹ค. ์ด๋Ÿด ๋•Œ, ์ฝ”๋“œ์— cout
ยทC++/๊ธฐํƒ€
C++์—์„œ ์ •์ˆ˜๋ผ๋ฆฌ ๋‚˜๋ˆ—์…ˆ์„ ํ•˜๊ฒŒ ๋˜๋ฉด, ์†Œ์ˆ˜์  ์ดํ•˜์˜ ์ˆซ์ž๋Š” ๋ฒ„๋ ค์ง‘๋‹ˆ๋‹ค. #include using namespace std; int main(){ int num1 = 10; int num2 = 3; float result = num1 / num2; cout
Chan Lee
'C++' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (13 Page)