wes d2a2ba9e15 first commit | %!s(int64=4) %!d(string=hai) anos | |
---|---|---|
.. | ||
README.md | %!s(int64=4) %!d(string=hai) anos | |
code.cpp | %!s(int64=4) %!d(string=hai) anos | |
unitTest.cpp | %!s(int64=4) %!d(string=hai) anos |
by CppPythonDude tags: conditions, language_fundamentals
There is a ?: operator in C++ and it's basic form is (condition) ? (something1) : (something2). To illustrate: if (condition) something1; else something2; Write a function that uses the ?: operator to return "yeah" if the condition is true, and "nope" otherwise. Examples yeahNope(true) ➞ "yeah" yeahNope(false) ➞ "nope" Notes N/A
There is a ?:
operator in C++ and it's basic form is (condition) ? (something1) : (something2)
.
To illustrate:
if (condition)
something1;
else
something2;
Write a function that uses the ?:
operator to return "yeah"
if the condition is true
, and "nope"
otherwise.
yeahNope(true) ➞ "yeah"
yeahNope(false) ➞ "nope"
N/A