Using the :? Operator

Published by CppPythonDude in

There is a ?: operator in C++ and its basic form is (condition) ? (something1) : (something2).

To illustrate:

if (condition)
  something1;
else
  something2;

Write a function that uses the ?: operator to return "yeah" if b is true, and "nope" otherwise.

Examples

yeahNope(true) ➞ "yeah"

yeahNope(false) ➞ "nope"

Notes

N/A

Watch a quick demo on how Edabit works.