C++ Operators C++ Operators are special symbols which are used to perform operations on operands . C++ is very rich in builtin operators. In fact it places more significance on operators than do most other computer languages. We can say that an operator is a symbol that causes the computer language. We can say that …
The post C plus plus Operators appeared first on SPEECHUS.
]]>1) Arithmetic (Mathematical) Operators
2) Relational Operators
3) Logical Operators
4) Assignment Operators
5) Increment and Decrement Operators
6) Bitwise Operators
Operators 
Action

Example

Result

+

Addition

10+10

20

–

Subtraction, Also may unary minus

2010

10

/

Division

20/4

5

*

Multiplication

10*10

100

%

Modulus(Remainder)

10%5

0

Relational operators are use to determine whether two numbers are equal, or if one is greater or less than the other. Every relational expression returns either 1(true) or 0(false).
Relational operators are also known as comparison operators.
There are six relational C++ operators: equals(==),less then(<),greater than(>),less than or equal to(<=), greater or equal to(>=),and not equals(!=).Table shows each relational operator, its use, and a simple code use.
Operators 
Name

Example

Result

==

Equals

200 == 100

False

!=

Not Equals

200! = 100

True

>

Greater Then

200>50

True

>=

Greater then or equals

200>=100

True

<

Less then

200<100

False

<=

Less then or equals

200<=100

False

Logical operators are used to join one or more relational expression.
Often you ask more than one relational question at a time.It is true that x is a greater then y,
And also true that y greater then Z?.
A program might need to determine that both of these conditions are true, or that some other condition is true, in order to take an action.
Operator 
Operator name

Example

Hazard to



Logical OR

5<23>1

true

!

Logical NOT

!5>2

false

&&

Logical AND

3>2&&2<8

true

Assignment operators is used to assigns values into a variable or constant. And operand that can legally be on the left side of a assignment operator is called and 1value.
And operand that can be on the right side is called rvalues. Constants rvalues, but not all rvalues are 1values. Thus you can write
X = 45 ;
//ok
But you cannot legally write
45=x;
//error, not an 1value!
And 1value is operand that can be on the left side all an expression. An rvalues than operand that can be on the right side of an expiration.
Note that all 1values are rvalues, but not all rvalues are 1values. An example of an rvalues that is not an
Unlike many other languages ,C/C++ supports a full complement of bitwise operators. Since C was designed to take the place of assembly language for most programming takes, it needed be able to support many operations that can be done in assembler, including operations refers to testing,
Setting ,or shifting the actual bits in a byte or word ,which correspond to the char and int data types and variants . You cannot use bit wise operations on float, double, long double ,void ,bool ,or other ,more complex types .Table 26 lists the operators that apply to bit wise operation .These operations are applied to the individual bits of the operations.
Operators

Action

&

AND



OR

^

Exclusive OR(XOR)

~

One’s complement(NOT)

>>

Shift right

<<

Shft left

C/C++ contains a very powerful and convenient operator that replaces certain statements of the ifthenelse from. The ternary operator (? takes the general form
Exp1?Exp2:Exp3;
Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.The? operator works like this: Exp1 is evaluated. If it is true ,Exp2 is evaluated and becomes the value of the expression.If Exp1 is false,Exp3 is evaluated and its value becomes the value of the expression. For Example ,in
X=10;
Y=x>9?100:200;
Y is assigned the value 100. If x had been than 9, Y would have received the value 200.
C++ Supports some special operators that are used for specific purpose .
The post C plus plus Operators appeared first on SPEECHUS.
]]>