C++

Topic: Operators

Explain about Relational and equality operators ( ==, !=, >, <, >=, <= ) ?

In order to evaluate a comparison between two expressions we can use the relational and equality operators. The result of a relational operation is a Boolean value that can only be true or false, according to its Boolean result.We may want to compare two expressions, for example, to know if they are equal or if one is greater than the other is. Here is a list of the relational and equality operators that can be used in C++:==	Equal to!=	Not equal to>	Greater than<	Less than>=	Greater than or equal to<=	Less than or equal toHere there are some examples:(7 == 5)     // evaluates to false.(5 > 4)      // evaluates to true.(3 != 2)     // evaluates to true.(6 >= 6)     // evaluates to true.(5 < 5)      // evaluates to false. Of course, instead of using only numeric constants, we can use any valid expression, including variables. Suppose that a=2, b=3 and c=6,(a == 5)     // evaluates to false since a is not equal to 5.(a*b >= c)   // evaluates to true since (2*3 >= 6) is true. (b+4 > a*c)  // evaluates to false since (3+4 > 2*6) is false. ((b=2) == a) // evaluates to true.  Be careful! The operator = (one equal sign) is not the same as the operator == (two equal signs), the first one is an assignment operator (assigns the value at its right to the variable at its left) and the other one (==) is the equality operator that compares whether both expressions in the two sides of it are equal to each other. Thus, in the last expression ((b=2) == a), we first assigned the value 2 to b and then we compared it to a, that also stores the value 2, so the result of the operation is true.

Browse random answers:

What is a scope resolution operator?
Why the constructor can't be virtual?
Why can't we overload the sizeof, :?, :: ., .* operators in c++?
Difference between a "assignment operator" and a "copy constructor"
Can you explain the term "resource acquisition is initialization?"
Difference between realloc() and free()?
Define copy constructor? What is the use of copy constructor?
Explain the scope resolution operator.
What is aggression and association?
In C++, what is a constructor,destructor?
How to convert ascii into number value like if i typed in the letter 'R' it would give me a value of 120 0r something ?
What problems might the following macro bring to the application?
What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.
What is the difference between a copy constructor and an overloaded assignment operator?
Hi I would like to know how to convert binary to decimal in c++?
What is a scope resolution operator?
What is function overloading and operator overloading?
How can you overload a method?
what is the difference between ==and.=operator
Assignment Operator - What is the diffrence between a "assignment operator" and a "copy constructor"?
What are operators?
What is the difference between operator new and the new operator?
Can you declare the override method static while the original method is non-static?
What is a scope resolution operator?
What is operator overloading in C++?  
What is overloading unary operator?  
What is function overloading and operator overloading?  
Explain about Arithmetic Operators with example ?
Explain about Relational Operators with example ?
What is function overloading?  
Explain about Relational and equality operators ( ==, !=, >, <, >=, <= ) ?
What are other operators ?
Explain about Precedence of operators with example ?
Explicit type casting operato ?r
Explain about Comma operator ( , ) ?
Explain about Bitwise Operators ( &, |, ^, ~, <<, >> )
Explain about Conditional operator ( ? ) with example ?
Explain about Logical operators ( !, &&, || ) with example ?
Explain about Increase and decrease (++, --) with example ?
Explain about Compound assignment (+=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=)
Explain about Arithmetic operators ( +, -, *, /, % ) ?
Explain about Assignment (=) ?
what is the operator overloading in c++
What is the difference between "overloading" and "overriding"?
How many ways can an argument be passed to a subroutine?
What is operator overloading?what r the advantages of operator overloading?
What is function overriding?
Can main() be overridden?
What is difference between overloading and overriding?
In C++, what is the difference between method overloading and method overriding?
Can destructor be private?
You?re given a simple code for the class Bank Customer. Write the following functions:* Copy constructor* = operator overload* == operator overload* + operator overload (customers? balances should be added up, as an example of joint account between husband and wife)
What is the need /use of function overloading
Can a method be overloaded based on different return type but same argument type ?
What is the difference between shadow and override?
What is the difference between a template class and class template?