If-Else Statement
noun
say it: “IF ELS STAYT-ment” /ɪf ɛls ˈsteɪtmənt/
A statement that runs one block of code when a condition is true and another when it is false.
What is an if-else statement?
A statement that executes one of two code blocks depending on a condition.
if(age < 21) {
price = 14.99;
} else {
price = 19.99
}
// statements with a single line of code
// can be written like this
if(age < 21) price = 14.99;
else price = 19.99;
In a sentence
- “The if-else statement prints "Win" or "Loss" depending on the score.”
Level: Novice · More C# terms at this level
Updated