Assigns x to y only if x is greater than y, using if statements. - C Statement

C examples for Statement:if

Description

Assigns x to y only if x is greater than y, using if statements.

Demo Code

#include <stdio.h>

int x, y;//from  w  ww. j ava  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");

    if (x > y)
        printf("x is greater than y\n");

    if (x < y)
        printf("x is smaller than y\n");

    return 0;
}

Result


Related Tutorials