If Statement
Posted by JanWan
Last Updated: March 05, 2012
/* Demonstrates the use of if statement */

#include <stdio.h>

int x, y;

main()
{
/* Input the two values to be tested */

printf("\nInput an integer value for X: ");
scanf("%d", &x);
printf("\nInput an integer value for Y: ");
scanf("%d", &y);

/* Test value and print result */

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;
}

Related Content