C examples for Operator:Logic Operator
For || Boolean operator, if either side of the condition is true, the whole expression results in true.
Truth Table for or Operator
x | y | Result |
---|---|---|
true | true | true |
true | false | true |
false | true | true |
false | false | false |
Checking for a Range of Values
#include <stdio.h> int main()/*ww w. j a v a2 s. c o m*/ { int iResponse = 0; printf("Enter a number from 1 to 10: "); scanf("%d", &iResponse); if ( iResponse < 1 || iResponse > 10 ) printf("\nNumber not in range\n"); else printf("\nThank you\n"); }