1.

What are arithmetic operators in C++? Distinguish between unary and binary arithmetic operators. Give examples for each of them.

Answer»

Following are the arithmetic operators in C++:

addition(+), subtraction(-), multiplication(*), division(/) and reminder(%).

Unary arithmetic operatorsBinary arithmetic operators 
Unary Operators has only one operandBinary operators (”bi” as in “two”) have two operands 
The Unary Operators are ++,--,&,*,+, - etc.The +, -, &&, <<, ==, >> etc. are binary operators.
Example: short x = 987; x = -x;Example:  int x, y = 5, z;
z = 10; x = y + z;


Discussion

No Comment Found

Related InterviewSolutions