by Dinesh Thakur Category: Operator

Boolean operators AND, OR, and NOT are used to manipulate logical statements. Boolean operators are the core operators used in digital control systems as well as computer systems. AND and OR are binary operators, while NOT is a unary operator. Let *A *and *B *be two logical statements or variables representing logical statements. If a logical statement is *true *it may be assigned the value 1, and if a logical statement is *false *it may be assigned the value 0. Table gives details of the three operators AND, OR, and NOT.

Complex Boolean expressions are often resolved with the help of truth tables. A truth table displays the conditions in which the expression will be true and when it will become false for all values of variables (either 0 or 1, i.e., 0 for *false *and 1 for *true). *For example, let us consider two logic statements *A *and *B. *If A is true, it has the value 1, and if it is *false *its value is 0. These values are substituted in the expression. If the expression evaluates to 1 the expression is said to be true, otherwise it is considered to be false. Table shows the truth table for !A, !B, A I I B, and A&&B.

Illustrates the application of **Boolean operators.**

#include <stdio.h>

main()

{

int A = 1, B = 0, C =1, S, X, Y, Z, H, F = 1;

clrscr();

S = A || B;

H =!B;

X= A &&!B ;

Y =!(A+B + A*B);

Z= (!A || !B && !C || F);

printf("S = %d\t H = %d\n" ,S, H);

printf("X = %d\t Y = %d\t Z = %d\n", X,Y,Z);

}

**Illustrates Boolean operators in if (expression).**

#include <stdio.h>

void main()

{

double A= 4.6, B= 0.0, C = -4.2, S, X, Y, Z, H, F =-7.5;

S = A || B;

H =A && F;

X= A && !B ;

Y =!(A+B + !A*B);

Z= (!A || !B && !C || F);

printf("S = %lf\t H = %lf\n" ,S, H);

printf("X = %lf\t Y = %lf\t Z = %lf\n", X,Y,Z);

if (!A || !B && !C || F)

printf("The logic expression= 1.\n");

if (A+B + !A*B)

printf( "The logic expression= 1.\n");

}

About Dinesh Thakur

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article

#### Define Operator, Operand, and Expression in 'C'

#### Which bitwise operator is suitable for checking whether a particular bit is ON or OFF

#### Define different types of Operators.

#### How does the prefix and postfix operator on expression

#### What is the functionality and restrictions of Modulus Operator

#### What is the difference between ++var and var++

#### Boolean Operators in C

#### What is Precedence of Operators

#### Bitwise Operators in C

#### Composite Assignment Operators in C

#### sizeof() operator in C

#### Relational and Equality Operators

#### Arithmetic Operators in C

#### Logical Operators in C

#### What is Operators in C language?

#### What is Precedence and Associativity of Operators?

#### What is conditional expression operator(ternary operator)?

#### What is Arithmetic operator in C language?

#### Assignment Operator in C

#### Const and volatile Qualifiers in C

Basic Courses

Advance Courses