0% found this document useful (0 votes)
10 views5 pages

Control Structures

Uploaded by

ssascw.bca
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)
10 views5 pages

Control Structures

Uploaded by

ssascw.bca
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
You are on page 1/ 5

Here are some notes on Control Structures:

1.Conditional Statements:
1. if:
o Syntax:

o Executes the code block only if the


condition evaluates to true.
2. else:
o Syntax:

o Provides an alternative code block that


runs if the condition is false.
3. elseif:
o Syntax:

o Allows checking multiple conditions in


sequence.
4. switch:
o Syntax:

o An alternative to multiple if-elseif


statements, particularly useful for
comparing the same variable against
different values.
2.Loops:
1. for:
o Syntax:

o Executes a code block a specific number


of times.
2. while:
o Syntax:

o Repeats a code block as long as the


condition is true.
3. do-while:
o Syntax:
o Similar to the while loop, but the code
block is executed at least once before the
condition is checked.
4. foreach:
o Syntax:

o Loops through each element in an array.


3.Control Statements:
1. break:
o Syntax:

o Exits from the loop or switch statement


immediately.
2. continue:
o Syntax:

o Skips the current iteration of a loop and


continues with the next iteration.
3. exit:
o Syntax:

o Terminates the script immediately. You


can optionally pass a status code or
message.

You might also like