C examples for Statement:if
Assigns x to y only if x is greater than y, using if statements.
#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; }