Conditional structures: Difference between revisions

Added C section. Surgery complete. :)
(Added AppleScript to the RIGHT page, this time.)
 
(Added C section. Surgery complete. :))
Line 12:
return "odd"
end if
 
==[[C]]==
[[Category:C]]
===if-then-else===
'''Compiler:''' [[GCC]] 4.1.2
int main (int argc, char ** argv) {
int input = 2;
if ( 3 == input ) {
// Do something
}
if ( 3 == input ) {
// Do something
} else {
// Do something else
}
}
 
===switch===
'''Compiler:''' [[GCC]] 4.1.2
int main (int argc, char ** argv) {
int input = 42;
switch (input) {
case 0:
// Do something, because input = 0
break;
case 1:
// Do something, because input = 1
break;
case 2:
// Do something, because input = 2
default:
// Do something else.
break; // Optional
}
}