Ternary if statement
There is a short way to write if statement: ternary if statement. The format is that (condition) ? [if true, here] : [if false, here] When using in cout, make sure to use parenthesis like below code. #include #include #include using namespace std; int main() { string weather = "sunny"; double humid = 0.7; weather = (humid > 0.5) ? "rainy" : "sunny"; cout
c++
2020. 7. 19. 00:45