Operators in C Language
Categories: C language
Operators in C is a special symbol used to perform the functions. The data items on which the operators are applied are known as operands. Operators are applied between the operands. Depending on the number of operands, operators are classified as follows:
Unary Operator
A unary operator is an operator applied to the single operand. For example: increment operator (++), decrement operator (--), sizeof, (type)*.
Binary Operator
The binary operator is an operator applied between two operands. The following is the list of the binary operators:
1. Arithmetic Operators
2. Relational Operators
3. Shift Operators
4. Logical Operators
5. Bitwise Operators
6. Conditional Operators
7. Assignment Operator
8. Misc Operator
Constants in C
A constant is a value assigned to the variable which will remain the same throughout the program, i.e., the constant value cannot be changed.
There are two ways of declaring constant:
1. Using const keyword
2. Using #define pre-processor
Types of constants in C
ConstantExample
Integer constant10, 11, 34, etc.
Floating-point constant45.6, 67.8, 11.2, etc.
Octal constant011, 088, 022, etc.
Hexadecimal constant0x1a, 0x4b, 0x6b, etc.
Character constant'a', 'b', 'c', etc.
String constant"java", "c++", ".net", etc.
Special characters in C
Some special characters are used in C, and they have a special meaning which cannot be used for another purpose.
Square brackets [ ]: The opening and closing brackets represent the single and multidimensional subscripts.
Simple brackets ( ): It is used in function declaration and function calling. For example, printf() is a pre-defined function.
Curly braces { }: It is used in the opening and closing of the code. It is used in the opening and closing of the loops.
Comma (,): It is used for separating for more than one statement and for example, separating function parameters in a function call, separating the variable when printing the value of more than one variable using a single printf statement.
Hash/pre-processor (#): It is used for pre-processor directive. It basically denotes that we are using the header file.
Asterisk (*): This symbol is used to represent pointers and also used as an operator for multiplication.