Conditional structures/C: Difference between revisions

m
→‎if-then-else: consistent indent; removed {{works with}}
m (often)
m (→‎if-then-else: consistent indent; removed {{works with}})
Line 2:
 
===if-then-else===
{{works with|gcc|4.1.2}}
 
<lang c>int main (int argc, char ** argv) {
int input = 2;
 
if ( 3 == input ) {
/* Do something */
}
 
 
if ( 3 == input ) {
/* Do something */
} else {
Line 21 ⟶ 20:
One line predicates do not require curly braces (although their usage is often preferred for readability):
 
<lang c>if (cond)
expr;
 
if (cond)
expr;
else
expr;</lang>
 
And these may be mixed:
 
<lang c>if (cond)
expr;
else
{
Line 37:
}</lang>
 
<lang c>if (cond)
{
/* multiple expressions */
Anonymous user