c unit 1.pptx
c unit 1.pptx
if (condition)
{
// code to be executed if condition is true
}
Example
If….else statement
► Syntax-
if (condition) {
// Code to execute if condition is true
}
else {
// Code to execute if condition is false
}
Example
If-else-if Ladder
► while (condition)
{
// code to be executed
}
Example
do-while Loop
► Syntax-
switch (expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
How it works: