DEV Community

Tania
Tania

Posted on • Originally published at kodlogs.com

How to use OR in c++

Or operator in c++

Contents
Overview
Discussion
|| truth table
Syntax
Example
Summary
Tags
Alt Text

Logical OR operator: ||

Overview
Operators that are used in Boolean algebra for various logical factors are called logical operators. Boolean algebra also has three basic operators: AND operator, OR operator, NOT operator, and operator used for Logical Multiplication. They are also denoted by a dot symbol in Boolean. Also used for OR operator Logical Addition. It is also denoted by a plus sign. In addition, the AND operator varies on variables or expressions. (BAR) or dash. It is also called complement operator. It negates or reverses the value of a variable. If the value of the variable is 1, it makes it 0. If yes, then it makes it 1. It was necessary to state this so that you can understand the logical operator well. These are the three basic operators. The operator we will talk about today is OR operator. The process of logical addition of variables or numbers is called OR operation. OR operators are used for OR operation. Let's try to understand it more.

Discussion

Now let's talk about how the OR operator works in C ++. The C language allows you to use the following logical operators in the if statement && which is commonly read as AND. || Which is usually read as OR. ! Which is usually read as NOT. The working style of these operators is something like this. If true, then the expression will be correct. The operator of! Denies any quantity or logical operation. Here, right means to be greater than or greater than 0 and wrong means to be 0. To understand these operators. Make some example.

|| (logical OR) operator truth table
false||false=false
false||true=true
true||false=true
true||true=true

Syntax

logical-or-expression || logical-and-expression

C++ Logical OR Operator

The logical OR operator || returns

true - if one or more of the operands are true.

false - if and only if all the operands are false.

Truth Table of || Operator

Let x and y be two operands. Then,

X ....y= x||y

Example : C++ OR Operator

Language AND OR NOT

C++ && || !
C# && || !
Java && || !
JavaScript && || !
Python and or not

Summary

Today we understand kodlog website, I try to explain or operator . I hope after reading this article you will be able to understand the or operator in c++. I would like to have feedback from my kodlog site. Please post your feedback, question, or comments about this article.

Tags

C#|Python |Python 3|pycharm |html|java|JavaScript |cpp|code|rubi|Network | Google |html5 |php|bootstrap |string |Microsoft |variable |syntax |Coders |Codinglove|
Computerscience|wordpress|html-page|php|
Xml|game| net| list | loop | integer |float | string | double |

Top comments (0)