> Online tutorial : operator in c
Showing posts with label operator in c. Show all posts
Showing posts with label operator in c. Show all posts

operator in c


An operator is something which takes one or more values and does something useful with those values to produce a result. It operates on them. The terminology of operators is the following:
operator
Something which operates on someting.
operand
Each thing which is operated upon by an operator is called an operand.
operation
The action which was carried out upon the operands by the operator!






  • Comparisons and Logic Operator



  • Arithmetic Operators



  • Operators and Precedence



  • The Cast Operator



  • Special Assignment Operators ++ and --

  • Assignment operator in c


    Special Assignment Operators ++ and --
    C has some special operators which cut down on the amount of typing involved in a program. This is a subject in which it becomes important to think in C and not in other languages. The simplest of these perhaps are the increment and decrement operators:

    ++
    increment: add one to
    --
    decrement: subtract one from
    These attach to any variable of integer or floating point type. (character types too, with care.) They are used to simply add or subtract 1 from a variable. Normally, in other languages, this is accomplished by writing:
    variable = variable + 1;

    In C this would also be quite valid, but there is a much better way of doing this:
    variable++; or
    ++variable;

    would do the same thing more neatly. Similarly:
    variable = variable - 1;

    is equivalent to:
    variable--;

    or
    --variable;

    Notice particularly that these two operators can be placed in front or after the name of the variable. In some cases the two are identical, but in the more advanced uses of C operators, which appear later in this book, there is a subtle difference between the two.