C Operators
C Operators
# Types of Operators in C
# Arithmetic Operators
# C Program to Add Two Numbers
# Increment and Decrement Operators
# Relational Operators
# Logical Operators
# Bitwise Operators
# Assignment Operators
# Conditional Operator
# Special Operators
# Program to demonstrate the use of sizeof operator
Types of Operators in C
C programming language offers various types of operators having different functioning
capabilities.
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increment and Decrement Operators
6. Conditional Operator
7. Bitwise Operators
8. Special Operators
Arithmetic Operators
Arithmetic Operators are used to performing mathematical calculations like addition (+),
subtraction (-), multiplication (*), division (/) and modulus (%).
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
−− Decrement
Output
void main()
{
//set a and b both equal to 5.
int a=5, b=5;
5 4
4 3
3 2
2 1
1 0
Relational Operators
Relational operators are used to comparing two quantities or values.
Operator Description
== Is equal to
!= Is not equal to
&& And operator. It performs logical conjunction of two expressions. (if both expressions
evaluate to True, result is True. If either expression evaluates to False, the result is
False)
Bitwise Operators
C provides a special operator for bit operation between two variables.
Operator Description
| Binary OR Operator
Assignment Operators
Assignment operators applied to assign the result of an expression to a variable. C has
a collection of shorthand assignment operators.
Operator Description
= Assign
Conditional Operator
C offers a ternary operator which is the conditional operator (?: in combination) to
construct conditional expressions.
Operator Description
?: Conditional Expression
Special Operators
C supports some special operators
Operator Description
* Pointer to a variable.
Program to demonstrate the use of sizeof operator
Example:
#include <stdio.h>
void main()
{
int i=10; /* Variables Defining and Assign values */
printf("integer: %d\n", sizeof(i));
}
Program Output: