Relational and logical operations : Operator Relation « Language Basics « C / ANSI-C






Relational and logical operations

Relational and logical operations
  
#include <stdio.h>

int main(void)
{
  int i, j;

  printf("Enter i: ");
  scanf("%d", &i);
  printf("Enter j: ");
  scanf("%d", &j);

  /* relational operations */
  printf("i < j %d\n", i < j);
  printf("i <= j %d\n", i <= j);
  printf("i == j %d\n", i == j);
  printf("i > j %d\n", i > j);
  printf("i >= j %d\n", i >= j);

  /* logical operations */
  printf("i && j %d\n", i && j);
  printf("i || j %d\n", i || j);
  printf("!i !j %d %d\n", !i, !j);

  return 0;
}
           
       








Related examples in the same category

1.Testing letters using and
2.Logical operator