Answer the question
In order to leave comments, you need to log in
How to replace such an if-else construct with a ternary operator?
int a = 10;
int b;
// b = a > 0 ? (a < 100 ? b = 1 : b = 0): b = -1;
if (a > 0) {
if (a < 100) {
b = 1;
} else {
b = 0;
};
}
else {
b = -1;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question