control

for (int i = 0; i < 3; i++) {
    printf("%d\n", i);
}

Declare the loop variable in the loop It dies at the end of the block

if

C treats zero as false and anything else as true There is no boolean type requirement in the condition Compare explicitly when the value is not already a flag

while and do

while checks first do while checks after, so the body runs at least once Use do while only when that guarantee is real

switch

switch falls through to the next case unless you break C23 adds [[fallthrough]] as an attribute to mark an intentional fallthrough An unmarked fallthrough is a bug waiting for a reviewer

Next

Functions in 05 functions

Posted