C language is a structured programming language, It is developed by Dennis Ritchie in 1973 at Bell Laboratories. It is one of the most popular computer languages today because of its structure, high-level abstraction, machine independent feature etc. C language was developed to write the UNIX operating system, hence it is strongly associated with UNIX, which is one of the most popular network operating system in use today and heart of internet data superhighway.
C Language Operators
- Arithmetic operators
- Relational operators
- Logical operators
- Bit-wise operators
- Assignment operators
- Conditional operators
- Special operators
Arithmetic operators
Operator |
Description |
+ |
adds two operands |
– |
subtract second operands from first |
* |
multiply two operand |
/ |
divide numerator by denominator |
% |
remainder of division |
++ |
Increment operator – increases integer value by one |
— |
Decrement operator – decreases integer value by one |
Relational operators
Operator |
Description |
== |
Check if two operand are equal |
!= |
Check if two operand are not equal. |
> |
Check if operand on the left is greater than operand on the right |
< |
Check operand on the left is smaller than right operand |
>= |
check left operand is greater than or equal to right operand |
<= |
Check if operand on left is smaller than or equal to right operand |
Logical operators
C language supports following 3 logical operators. Suppose a = 1
and b = 0
,
Operator |
Description |
Example |
&& |
Logical AND |
(a && b) is false |
|| |
Logical OR |
(a || b) is true |
! |
Logical NOT |
(!a) is false |
Bit-wise Operators
Bit-wise operators perform manipulations of data at bit level. These operators also perform shifting of bits from right to left.
Operator |
Description |
& |
Bit-wise AND |
| |
Bitwise OR |
^ |
Bit-wise exclusive OR |
<< |
left shift |
>> |
right shift |
Assignment Operators
Operator |
Description |
Example |
= |
assigns values from right side operands to left side operand |
a = b |
+= |
adds right operand to the left operand and assign the result to left |
a + = b is same as a = a + b |
-= |
subtracts right operand from the left operand and assign the result to left operand |
a – = b is same as a = a – b |
*= |
multiply left operand with the right operand and assign the result to left operand |
a * = b is same as a = a * b |
/= |
divides left operand with the right operand and assign the result to left operand |
a / = b is same as a = a / b |
%= |
calculate modulus using two operands and assign the result to left operand |
a % = b is same as a = a % b |
Special Operator
Operator |
Description |
Example |
sizeof |
Returns the size of an variable |
sizeof(x) return size of the variable x |
& |
Returns the address of an variable |
&x ; return address of the variable x |
* |
Pointer to a variable |
*x ; will be pointer to a variable x |
Features of C Language
- C is a structured programming language with fundamental flow control construction.
- It is simple and versatile language
- Programs written in C are efficient and fast.
- C language has rich set of operators.
- C permits all data conversions and mixed mode operations
- Dynamic memory allocation(DMA) is possible in C.
- Extensive varieties of data types such as arrays, pointers, structures and unions are available in C.
- C improves by itself. It has several predefined functions.
- It can easily manipulates bits, bytes and addresses.
- Recursive function calls for algorithmic approach is possible in C.