Caleb koech
DCS/4492/2026
Differentiate between an operator and operand in C.
Operator – the symbol that specifies the operation to be performed.
Operand – the data item on which the operator acts.
Explain the different types of operators in C.
Category Description
Arithmetic Perform mathematical calculations.
Relational Compare values and produce a Boolean
result.
Logical Combine or invert Boolean expressions.
Bitwise Operate on individual bits of integer
types.
Assignment Assign values to variables.
Increment/Decrement Increase or decrease a variable’s value by
one.
Conditional (ternary)a Provide a shorthand if‑else expression.
sizeof Determine the size (in bytes) of a type or
variable.
Comma Separate multiple expressions where only
one is expected.
Pointer Access the address of a variable or the
value at an address.
example of a C program that demonstrates various operators:
#include
int main() {
int a = 10, b = 5, c;
// Arithmetic Operators
printf("Arithmetic Operators:\n");
printf("a + b = %d\n", a + b);
printf("a - b = %d\n", a - b);
printf("a * b = %d\n", a * b);
printf("a / b = %d\n", a / b);
printf("a %% b = %d\n", a % b); // Modulus operator
// Relational Operators
printf("\nRelational Operators:\n");
printf("a == b: %d\n", a == b);
printf("a != b: %d\n", a != b);
printf("a > b: %d\n", a > b);
printf("a < b: %d\n", a < b);
printf("a >= b: %d\n", a >= b);
printf("a <= b: %d\n", a <= b);
// Logical Operators
printf("\nLogical Operators:\n");
printf("a > 5 && b < 10: %d\n", a > 5 && b < 10);
printf("a > 5 || b > 10: %d\n", a > 5 || b > 10);
printf("!(a > 5): %d\n", !(a > 5));
// Assignment Operators
printf("\nAssignment Operators:\n");
c = a;
printf("c = a: %d\n", c);
c += a; // c = c + a
printf("c += a: %d\n", c);
c -= a; // c = c - a
printf("c -= a: %d\n", c);
// Increment/Decrement Operators
printf("\nIncrement/Decrement Operators:\n");
printf("a++: %d\n", a++); // Post-increment
printf("a: %d\n", a); // Value of a after increment
printf("b--: %d\n", b--); // Post-decrement
printf("b: %d\n", b); // Value of b after decrement
// Conditional Operator
printf("\nConditional Operator:\n");
int max = (a > b) ? a : b;
printf("Max of a and b: %d\n", max);
return 0;
}