Operators in C Programming
Operators in C Programming
Introduction to Operators in C
Operators in C programming are symbols used to perform operations on variables and values. They are essential for performing calculations, comparisons, and logical operations in a program.
Understanding operators in C programming helps you write efficient and functional code.
Types of Operators in C Programming
C programming provides different types of operators based on their functionality.
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations.
List of Arithmetic Operators
+Addition-Subtraction*Multiplication/Division%Modulus
Example
int main() {
int a = 10, b = 5;
printf(“Addition: %d\n”, a + b);
printf(“Subtraction: %d\n”, a – b);
printf(“Multiplication: %d\n”, a * b);
printf(“Division: %d\n”, a / b);
printf(“Modulus: %d\n”, a % b);
return 0;
}
Relational Operators
Relational operators are used to compare two values.
List of Relational Operators
==Equal to!=Not equal to>Greater than<Less than>=Greater than or equal to<=Less than or equal to
Example
int main() {
int a = 10, b = 5;
printf(“a > b: %d\n”, a > b);
printf(“a == b: %d\n”, a == b);
return 0;
}
Logical Operators
Logical operators are used to combine conditions.
List of Logical Operators
&&Logical AND||Logical OR!Logical NOT
Example
int main() {
int a = 10, b = 5;
printf(“(a > 5 && b < 10): %d\n”, (a > 5 && b < 10));
printf(“(a < 5 || b < 10): %d\n”, (a < 5 || b < 10));
return 0;
}
Assignment Operators
Assignment operators are used to assign values to variables.
Common Assignment Operators
=Assign+=Add and assign-=Subtract and assign*=Multiply and assign/=Divide and assign
Example
int main() {
int x = 10;
x += 5;
printf(“Value of x: %d”, x);
return 0;
}
Why Operators are Important
Benefits
- Perform calculations easily
- Make decision-making possible
- Help in writing logical conditions
- Improve program efficiency
Start Learning C Programming
Practice using different operators to improve your understanding of C programming.
Summary
Operators in C programming are used to perform operations on data. They include arithmetic, relational, logical, and assignment operators.
FAQs
What are operators in C programming?
Operators are symbols used to perform operations on variables and values.
What are arithmetic operators?
They are used to perform mathematical operations like addition and multiplication.
What are logical operators?
They are used to combine conditions in a program.
Why are operators important in C?
Operators help in calculations, comparisons, and decision-making.



