What are Operators in C

Operators are symbols used in C programming that represent various operations that can be carried out on variables or values. A few of these operations are arithmetic, logical, bitwise, assignment, and others. They can be roughly divided into numerous types:

  1. Arithmetic Operators: These operators are used to perform arithmetic operations on numeric values.

    • + (Addition)
    • - (Subtraction)
    • * (Multiplication)
    • / (Division)
    • % (Modulus, returns the remainder of division)
  2. Relational Operators: These operators are used to compare values and determine relationships between them.

    • == (Equal to)
    • != (Not equal to)
    • < (Less than)
    • > (Greater than)
    • <= (Less than or equal to)
    • >= (Greater than or equal to)
  3. Logical Operators: These operators are used to perform logical operations on boolean values.

    • && (Logical AND)
    • || (Logical OR)
    • ! (Logical NOT)
  4. Bitwise Operators: These operators are used to perform bitwise operations on binary representations of values.

    • & (Bitwise AND)
    • | (Bitwise OR)
    • ^ (Bitwise XOR)
    • ~ (Bitwise NOT)
    • << (Left shift)
    • >> (Right shift)
  5. Assignment Operators: These operators are used to assign values to variables.

    • = (Assignment)
    • += (Add and assign)
    • -= (Subtract and assign)
    • *= (Multiply and assign)
    • /= (Divide and assign)
    • %= (Modulus and assign)
    • &= (Bitwise AND and assign)
    • |= (Bitwise OR and assign)
    • ^= (Bitwise XOR and assign)
    • <<= (Left shift and assign)
    • >>= (Right shift and assign)
  6. Increment and Decrement Operators: These operators are used to increment or decrement the value of a variable by one.

    • ++ (Increment)
    • -- (Decrement)
  7. Conditional (Ternary) Operator: This operator provides a compact way to write conditional expressions.

    • condition ? expression_if_true : expression_if_false
  8. Comma Operator: This operator is used to separate expressions within a statement or function argument list.

    • , (Comma)
  9. Pointer Operators: These operators are used to work with pointers.

    • * (Pointer dereference)
    • -> (Member access through a pointer)

Remember that operator precedence determines the order in which operators are evaluated when multiple operators are used in an expression. It's crucial to understand operator precedence to write correct and meaningful C expressions.