0% found this document useful (0 votes)
44 views6 pages

Conditional Statements Guide

The document outlines different types of conditional statements in programming, specifically focusing on 'if-else' and 'switch' statements. It describes the structure and usage of these statements, including optional blocks and the ternary operator. Additionally, it highlights properties of switch statements, such as the order of cases and the allowance of nested switches.

Uploaded by

Demon God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views6 pages

Conditional Statements Guide

The document outlines different types of conditional statements in programming, specifically focusing on 'if-else' and 'switch' statements. It describes the structure and usage of these statements, including optional blocks and the ternary operator. Additionally, it highlights properties of switch statements, such as the order of cases and the allowance of nested switches.

Uploaded by

Demon God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Conditional Statements

Types

if-else Switch
if-else

if(Condition) {
//do something if TRUE
}
else {
//do something if FALSE
}

Ele is optional block


can also work without {}
else if

if(Condition 1) {
//do something if TRUE
}
else if (Condition 2) {
//do something if 1st is FALSE & 2nd is TRUE
}
Conditional Operators
Ternary
Condition ? doSomething if TRUE : doSomething if FALSE;

give 1 & 0 cases


Conditional Operators
switch
switch(number) {
case C1: //do something
break;
case C2 : //do something
break;
default : //do something
}
Conditional Operators
switch Properties

a. Cases can be in any order

b. Nested switch (switch inside switch) are allowed

You might also like