Logical Operators in Solidity Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Logical Operators are used to combining two or more conditions. Solidity has the following types of logical operators: Logical AND: Logical AND takes two operands and gives the valid Boolean result. The logical AND operator evaluates to true when all the operands are true (non-zero) otherwise false(zero). It is denoted by &&.Logical OR: Logical OR takes two operands and gives the valid Boolean result. The logical OR operator evaluates to true when at least one of the operands is true (non-zero) or otherwise false(zero). It is denoted by ||.Logical NOT: Logical NOT takes one operand and gives its complement as the result. The logical NOT operator evaluates to true (non-zero) if the operand is false (zero) and vice-versa. It is denoted by !.Operation DenotationDescriptionLogical AND&& It evaluates to true when all the operands are true (non-zero) otherwise false (zero)Logical OR|| It evaluates to true when at least one of the operands is true (non-zero) otherwise false (zero)Logical NOT ! It evaluates to true (non-zero) if the operand is false (zero) and vice-versa These logical operators are used to evaluate conditions in different situations. Below is the Solidity program to implement the Logical Operators: Solidity // Solidity program to implement // the Logical Operators pragma solidity ^0.5.0; contract logical { function logicaloperator (bool a , bool b) public pure returns (bool, bool, bool) { // Logical AND bool logicaland = a && b; // Logical OR bool logicalor = a || b; // Logical NOT bool logicalnot = !b; return (logicaland, logicalor, logicalnot); } } Output: Let us have two Boolean variables a and b. Case 1: When a is true and b is false. Case 2: When a is false and b is false. Case 3: When a is true and b is true. Case 4: When a is false and b is true. Comment More infoAdvertise with us Next Article Logical Operators in Solidity A aayushi2402 Follow Improve Article Tags : Solidity Solidity-Basics Similar Reads SQL - Logical Operators SQL Logical Operators are essential tools used to test the truth of conditions in SQL queries. They return boolean values such as TRUE, FALSE, or UNKNOWN, making them invaluable for filtering, retrieving, or manipulating data. These operators allow developers to build complex queries by combining, n 9 min read Logical Operators in Programming Logical Operators are essential components of programming languages that allow developers to perform logical operations on boolean values. These operators enable developers to make decisions, control program flow, and evaluate conditions based on the truthiness or falsiness of expressions. In this a 3 min read C++ Logical Operators In C++ programming languages, logical operators are symbols that allow you to combine or modify conditions to make logical evaluations. They are used to perform logical operations on boolean values (true or false).In C++, there are three logical operators:Table of ContentLogical AND Operator ( & 3 min read VBA Logical Operators in Excel Logical operators are used for performing logical and arithmetic operations on a set of values or variables. VBA allows you to use the Logical operators AND, OR, NOT, and XOR to compare values. The operators are considered "Boolean" which means they return True or False as a result. In Excel VBA, lo 6 min read Logical OR operator in Programming In programming, Logical operators play a crucial role in manipulating individual bits of data. One of the fundamental logical operators is the Logical OR operator(||).In this article, weâll dive deep into what is a Logical OR operator, its syntax, properties, applications, and optimization technique 5 min read Like