If – block in C Language

This “If-block C language Training ” post providing information about syntax of if-block, execution flow using flow chart and basic examples to understand the concept clearly.


 

if-block : Execute a block of instructions when the given condition is true.

 

 

Note : In C programming language only “0” is the false value. Remaining integer values( either +ve or -ve) are all true values.

void main()
{
    if(-17)
    {
        printf(“Hi\n”);
        printf(“Hello\n”);
    }
    printf(“Outer statement of if-block\n”);
}

 

Note : If we don’t specify the body ( { } ) of if-block, the statement which is followed by if-block consider as if-statement implicitly.

void main()
{
    if(!9)
        printf(“Hi\n”);
        printf(“Hello\n”);
}
output : Hello

Share this