CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Nested Ternary Evaluation

C++ code walkthrough · Question 23
mediumOperators

Code

Read carefully. What does this print?
1#include <iostream>
2#include <string>
3using namespace std;
4int main() {
5 int n = 0;
6 string s = n > 0 ? "positive" : n < 0 ? "negative" : "zero";
7 cout << s << endl;
8 return 0;
9}

Your answer