Junior — Middle
Can you explain what a binary operator is in programming?
sobes.tech AI
Answer from AI
A binary operator is an operator that takes two operands and performs a specific operation on them. In programming, such operators are widely used for arithmetic, logical, and other operations.
Examples of binary operators:
- Arithmetic:
+,-,*,/,% - Logical:
&&(logical AND),||(logical OR) - Comparison operators:
==,!=,<,>
For example, in the expression a + b, the + operator is binary because it operates on two operands a and b.
int a = 5;
int b = 3;
int sum = a + b; // '+' is a binary operator