Operators
1. Operators
Operators in C are symbols that perform operations on variables and values. They are classified into several categories:
1.1. Arithmetic Operators
Used for basic arithmetic operations:
Addition:
+
Subtraction:
-
Multiplication:
*
Division:
/
Modulus (remainder):
%
1.2. Relational Operators
Used to compare values:
Equal to:
==
Not equal to:
!=
Greater than:
>
Less than:
<
Greater than or equal to:
>=
Less than or equal to:
<=
1.3. Logical Operators
Used to perform logical operations:
Logical AND:
&&
Logical OR:
||
Logical NOT:
!
1.4. Bitwise Operators
Operate on bits and perform bit-level operations:
Bitwise AND:
&
Bitwise OR:
|
Bitwise XOR:
^
Bitwise NOT:
~
Left Shift:
<<
Right Shift:
>>
1.5. Assignment Operators
Used to assign values to variables:
Simple Assignment:
=
Add and Assign:
+=
Subtract and Assign:
-=
Multiply and Assign:
*=
Divide and Assign:
/=
Modulus and Assign:
%=
1.6. Increment and Decrement Operators
Used to increase or decrease the value of a variable:
Increment:
++
Decrement:
--
1.7. Conditional (Ternary) Operator
A shorthand for if-else statements:
1.8. Sizeof Operator
Used to get the size of a variable or type in bytes:
2. Instructions
Instructions in C are the basic commands that the compiler translates into machine code. Here are a few key instructions:
2.1. Assignment
2.2. Control Flow Instructions
if Statement
else Statement
switch Statement
while Loop
for Loop
do-while Loop
2.3. Function Calls
To call a function:
2.4. Return Statement
Returns a value from a function and exits the function:
2.5. Break and Continue
break: Exits the current loop or switch statement
continue: Skips the rest of the code in the current loop iteration and starts the next iteration
Summary
Operators in C include arithmetic, relational, logical, bitwise, assignment, increment/decrement, conditional, and sizeof operators.
Instructions include assignment, control flow statements (
if
,else
,switch
), loops (while
,for
,do-while
), function calls,return
, and loop control (break
,continue
)(We'll study more about them in Control Flow).
Last updated
Was this helpful?