Basic Operators
Operators in C are symbols that perform operations on variables and values. Here is an overview of basic operators in C:
1. Arithmetic Operators
Arithmetic operators perform mathematical operations on numerical values.
Addition (
+
): Adds two operands.Subtraction (
-
): Subtracts the right operand from the left operand.Multiplication (
*
): Multiplies two operands.Division (
/
): Divides the left operand by the right operand.Modulus (
%
): Returns the remainder when the left operand is divided by the right operand.
2. Assignment Operator
The assignment operator (=
) is used to assign a value to a variable.
3. Comparison Operators
Comparison operators compare two values and return a Boolean result (true
or false
).
Equal to (
==
): Checks if two values are equal.Not equal to (
!=
): Checks if two values are not equal.Greater than (
>
): Checks if the left operand is greater than the right operand.Less than (
<
): Checks if the left operand is less than the right operand.Greater than or equal to (
>=
): Checks if the left operand is greater than or equal to the right operand.Less than or equal to (
<=
): Checks if the left operand is less than or equal to the right operand.
4. Logical Operators
Logical operators perform logical operations and return a Boolean result.
Logical AND (
&&
): Returnstrue
if both operands aretrue
.Logical OR (
||
): Returnstrue
if at least one operand istrue
.Logical NOT (
!
): Returnstrue
if the operand isfalse
, and vice versa.
Conclusion
These basic operators in C provide the foundation for performing various operations in your programs. As you progress, you'll encounter more operators and gain a deeper understanding of their usage.
In the upcoming sections, we'll explore more advanced topics in C programming. If you have specific questions or areas you'd like to delve into further, feel free to ask. Happy coding!