Demonstrates the use of if statement with else clause - C Statement

C examples for Statement:if

Description

Demonstrates the use of if statement with else clause

Demo Code

#include <stdio.h>

int x, y;/* w w w. j av a 2 s  .c o  m*/

int main( void )
{
    printf("\nInput an integer value for x: ");

    scanf("%d", &x);

    printf("\nInput an integer value for y: ");

    scanf("%d", &y);


    if (x == y)
        printf("x is equal to y\n");
    else
        if (x > y)
            printf("x is greater than y\n");
        else
            printf("x is smaller than y\n");

    return 0;
}

Result


Related Tutorials