Hello #TC1017 as mi title says this post is about nested conditionals. #Mastery18
In addition to chaining of conditionals you can nest one conditional to another. Like in the example below:
if (x == 0) {
cout << "x is zero" << endl;
}
else {
if (x > 0) {
cout << "x is positive" << endl;
} else {
cout << "x is negative" << endl;
}
}
I put the code before in my editor and I compliled and run it to see how it works, I realize that actually it works!! So, we can nest conditionals into another conditionals.
Nested conditionals. by Gonzalo Mata is licensed under a Creative Commons Attribution 4.0 International License.