Operators in C

Operators in C programming Language


An operator is a symbol that instructs C to perform some operation, or action, on one or more operands.  Operator which requires 1 operand (something where operator acts on) is called unary operator, operators which requires 2 operators are called binary operators and the operator which requires 3 operands is ternary operator.


For example: 

Operators in C, operands in c, operator and operand, my knowledge to you dude



There are different types of operators in C

Arithmetic Operators
Relational Operators
Equality operators
Logical Operators
Assignment Operators etc.

  • Arithmetic Operators:


An arithmetic is used for basic operations such as addition, subtraction and multiplication ( mathematical and arithmetic calculations). C has 5 arithmetic operators.


Operator
Meaning of Operator
Example
+
addition
A+B
-
subtraction
A-B
*
multiplication
A*B
/
division
A/B
%
remainder
A%B


  • Relational Operators:

A relational operator checks the relationship between two different  operands. C provides 4 relational operators. It gives the result in terms of  true ( 1 ) and false ( 0 ).


Operator
Meaning of Operator
Example
< 
Less than
A<B
> 
Greater than
A>B
<=
Less than equal to
A<=B
>=
Greater that equal to
A>=B

  • Equality operators 
The operator which is used to compare two operands to check their equality is known as equality operators.

Operator
Meaning of Operator
Example
==
Equal to
A==B
!=
Not equal to
A!=B


  • Logical Operators 
The operator which logically connect the logical expression is called logical operator. It gives the result in binary value ( true = 1 and false = 0)

Operator
Meaning of Operator
Example
&&(AND)
True only if all operands are true.
A&&B
.. (OR)
True only if either one operand is true.
A..B
! (NOT)
True only if the operand is false.
!A


  • Assignment Operators
An assignment operator is used for assigning a value to a variable. The most common assignment operator is ‘=’.

Operator
Meaning of Operator
Example
+=
Add and assign
A+=B
(A=A+B)
-=
Subtract and assign
A-=B
(A=A-B)
*=
Multiply and assign
A*=B
(A=A*B)
/=
Divide and assign
A/=B
(A=A/B)
%=
Remainder and assign
A%=B
(A=A%B)





Post a Comment

0 Comments