C++ || Operators with c++

 Programming codester 

Operators with c++: 



 

In the previous tutorial we learnt about arithmetic and assignment operator with c++. 

Now let's learn other operators! 

We already know there are six types of operators! 

 

 Now let's learn about Logical operator, Bitwise operator, Relational operator, and other operators. 

1.logical operators: 

Logical operators are used to check whether an expression is true or false. If the expression is true, it returns 1 whereas if the expression is false, it returns 0. 

Operator 

Example 

Meaning 

&& 

expression1 && expression2 

Logical AND. 
True only if all the operands are true. 

|| 

expression1 || expression2 

Logical OR. 
True if at least one of the operands is true. 

! 

! expression 

Logical NOT. 
True only if the operand is false. 

In C++, logical operators are commonly used in decision making. To further understand the logical operators, let's see the following examples, 

 

OUTPUT: 

 

2. Relational Operator: 

Relational operator is also known as comparison operator. 

Comparison operators are used to compare two values (or variables). This is important in programming, because it helps us to find answers and make decisions. 

The return value of a comparison is either 1 or 0, which means true (1) or false (0). These values are known as Boolean values, and you will learn more about them in the Booleans and If. Else chapter. 

In the following example, we use the greater than operator (>) to find out if 5 is greater than 3: 

 

 

A list of all comparison operators: 

Operator 

Name 

Example 

== 

Equal to 

x == y 

!= 

Not equal 

x! = y 

> 

Greater than 

x > y 

< 

Less than 

x < y 

>= 

Greater than or equal to 

x >= y 

<= 

Less than or equal to 

x <= y 

C tutorials: 

Technology: 


TODAYS QUESTION: What is #include <stdio.h>?

a) Preprocessor directive

b) Inclusion directive

c) File inclusion directive

d) None of the mentioned

Ans is A


Thank you for your support! 

Learn and explore! 

 

 

 

 

Comments

Popular posts from this blog

C programming | Printf and scanf ||

C programming | structure | Fundamentals of Structure

C programming | Fundamentals & Basic information

Basic question related programming || c programming || embedded programming

C++ || string with c++ || Part - 1

Compiler & Interpreter | difference and explanation

c++|operators with c++|variables||

C programming | Nested structure | Array, function and pointer of structure|| structure Part-II

C++(oop)| Fundamentals | Concepts||