|
|||
Department of Engineering | |
University of Cambridge > Engineering Department > computing help |
... if (i==3) /* checking for equality; `!=' tests for inequality */ /* no braces needed for a single statement */ j=4; else{ /*the braces are necessary if the clause has more than one statement */ j=5; k=6; } ...
... /* switch is like the case statement in pascal. The values that the switching variable is compared with have to be constants, or `default'. */ switch(i){ case 1: printf("i is one\n"); break; /* if break wasn't here, this case will fall through into the next. */ case 2: printf("i is two\n"); break; default: printf("i is neither one nor two\n"); break; } ...