Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

if Statement

if statement has the following syntax:

if (expr)
    statement-block | { statement-block * }
    statement-block | { statement-block * }

    statement | field-declaration

expr is evaluated at run-time and if true, the first statement-block is evaluated, otherwise, the second statement-block is evaluated. If it is omitted and expr is false, nothing is evaluated and control flows to the next statement or declaration. If multiple statements or declarations need to be specified in the body of if or else, use the curly braces. For example:

struct A
    int a;
    if (a>0)
        float b;
        double b;
        int c;