cout << "NO\0YES\0"[3 * CONDITION] << endl; doesn't work because [] on const char * only gives you one char, i.e. 'N' or 'Y'. On the other hand, it can be replaced by cout << (3 * CONDITION)["NO\0YES\0"] << endl;.