Variables and Operators
By: Mustafif Khan
Language: C
Variables and Operators
Variables
// Variable declaration
datatype variable_name;
// Initialization
datatype variable_name = value;
// Common data types
int // Integer
float // Floatingpoint number
char // Character
double // Doubleprecision floatingpoint number

Variable Declaration: In C, you declare variables by specifying their data type followed by the variable name. This informs the compiler about the type of data the variable can hold.

Initialization: You can initialize a variable at the time of declaration by providing an initial value. If an initial value is not provided, the variable contains garbage values.

Common Data Types: C provides various data types to represent different kinds of values, including integers, floatingpoint numbers, characters, and doubleprecision floatingpoint numbers.
Operators
Arithmetic Operators
These operators perform basic mathematical operations.
// Addition: +
// Subtraction: 
// Multiplication: *
// Division: /
// Modulus (remainder): %
Assignment Operators
Assignment operators are used to assign values to variables. Compound assignment operators combine an operation with assignment.
// Assignment: =
// Addition assignment: +=
// Subtraction assignment: =
// Multiplication assignment: *=
// Division assignment: /=
// Modulus assignment: %=
Increment and Decrement Operators
These operators increase or decrease the value of a variable by 1.
// Increment by 1: ++
// Decrement by 1: 
Relational Operators
Relational operators compare two values and return a Boolean result.
// Equal to: ==
// Not equal to: !=
// Greater than: >
// Less than: <
// Greater than or equal to: >=
// Less than or equal to: <=
Logical Operators
Logical operators perform logical operations on Boolean values.
// Logical AND: &&
// Logical OR: 
// Logical NOT: !
Bitwise Operators
Bitwise operators work at the bit level and are often used for lowlevel bit manipulation.
// Bitwise AND: &
// Bitwise OR: 
// Bitwise XOR (exclusive OR): ^
// Bitwise NOT (complement): ~
// Left shift: <<
// Right shift: >>
Conditional (Ternary) Operator
This operator is a shorthand way to write an ifelse statement in a single line.
condition
? expression_if_true
: expression_if_false
Assignment Operators
These operators perform an operation and assignment in a single step, making code more concise
x += y; // Equivalent to x = x + y;
x = y; // Equivalent to x = x  y;
x *= y; // Equivalent to x = x * y;
x /= y; // Equivalent to x = x / y;
x %= y; // Equivalent to x = x % y;