Condition Components
What basic ideas underlie a structured conditional statement?
- Condition to test
- Statement block
- Else (optional)
C example
if ( a > b )
{
do_something();
do_anotherThing();
do_aThirdThing();
}
else
{
do_somethingElse();
do_anotherOtherThing();
}
What about loops?
- Condition to test
- Statement block
- Assumption that when the condition is false, we jump to the
statement after the block
C example
while ( a > b )
{
do_something();
do_anotherThing();
do_aThirdThing();
}
But assembly languages don't have blocks!
Alyce Brady, Kalamazoo College