C Programming Operators
An operator is a symbol that instructs C to perform some operation, or action, on one or more operands. An operand is something that an operator acts on. In C, all operands are expressions. C operators fall into several categories:
1) The assignment operator.
2) Mathematical operators.
3) Relational operators.
4) Logical operators.
The assignment operator
The assignment operator is the equal sign (=). Its use in programming is somewhat different from its use in regular math.If you write ….
x = y;
in a C program, it doesn’t mean “x is equal to y.” Instead, it means “assign the value of y to x.” In a C assignment statement, the right side can be any expression, and the left side must be a variable name.
Mathematical operators
C’s mathematical operators perform mathematical operations such as addition and subtraction. C has two unary mathematical operators and five binary mathematical operators.
The Unary Mathematical Operators
Increment ++ Increments the operand by one ++x, x++
Decrement -- Decrements the operand by one --x, x--
The binary mathematical operators
Addition + Adds two operands x + y
Subtraction - Subtracts the second x - y operand from the first operand
Multiplication * Multiplies two operands x * y
Division / Divides the first operand x / y by the second operand
Modulus % Gives the remainder x % y when the first operand is divided by
the second operand
The Relational Operators
C’s relational operators are used to compare expressions, asking questions such as, “Is x greater than 100?” or “Is y equal to 0?”An expression containing a relational operator evaluates to either true (1) or false (0). C’s six relational operators …..
The Logical Operators
Sometimes you might need to ask more than one relational question at once. For example, “If it’s 7:00 a.m. and a weekday and not my vacation, then ring the alarm.” C’s logical operators let you combine two or more relational expressions into a single expression that evaluates to either true or false.C’s three logical operators