Skip to main content

Write about If...else statement


The general form of a simple if...else statement is,

if(expression)
        {
            statement block1;
        }
        else
        {
            statement block2;
        }


If the expression is true, the statement-block1 is executed, else statement-block1 is skipped and statement-block2 is executed.

#include <stdio.h>

    void main( )
    {
        int x, y;
        x = 15;
        y = 18;
        if (x > y )
        {
            printf("x is greater than y");
        }
        else
        {
            printf("y is greater than x");
        }
    }


Output :

y is greater than x

written by -