Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
The simplest decision-making construct. The code block executes only when the condition evaluates to true.
if (condition) {
// executes when true
}int n = 10;
if (n > 0) {
cout << n << " is positive";
}if (age >= 18 && hasID) {
cout << "Entry allowed";
}If the body has only one statement, braces are optional — but always use them for readability and to prevent bugs when adding more lines later.