Operators in C Programming languages

There are some Operators in C Programming languages which performs different operations,they are:

1. Arithmetic operators
      C provides all the basic arithmetic operators. The operators +,-,* and / all work the same way as they do in other languages. These can operate on any built-in data type allowed in C. The unary minus operator, in effect, multiplies its single operand by -1. Therefore, a number preceded by a minus sign chages its sign.

2. Increment and Decrement operators
      The increment operator ++ and decrement operator – are unary operators with the same precedence as the unary -, and they all associate from right to left. Both ++ and – can be applied to variables, but no to constants or expressions. They can occur in either prefix or postfix position, with possibly different effects occurring. These are usually used with integer data type.

General syntax
++variable|--variable| variable++| variable—

3. Relational operators

We often compare two quantities and depending on their relation, to take certain decisions. For example, we may compare the age of two persons, or the price of two items, and so on. These comparisons can be done with the help of relational operators. C supports six relational operators in all.

Relational Operators are:

Operator      Meaning
<            is less than
>            is greater than
<=           is less than or equal to
>=           is greater than or equal to
= =          is equal to
!=           is not equal to

4. Logical operators

In addition to the relational operators . C has the following three logical operators.
&& logical AND
|| logical OR
! logical NOT
The logical operators && and || are used when we want to test more than one condition and make decisions.

5. Bitwise operators

Bitwise operators may not be applied to float or double. where the filename is the name containing the required definitions or functions. At this point, the preprocessor inserts the entire contents of the filename into the source code of the program. When the filename is included within the double quotation marks, the search for the file is made first in the directory and then in the standard directories.

Bitwise Operators are:

Operator        Meaning
&              bitwise AND
!              bitwise OR
^              bitwise exclusive OR
<<             shift left
>>             shift right
~              One’s Complement
Operators in C Programming languages Operators in C Programming languages Reviewed by Unknown on 07:59 Rating: 5

No comments:

Powered by Blogger.