- Performing basic arithmetic operations: addition, subtraction, multiplication, division, and modulus
- Understanding how bitwise AND, OR, and XOR operators work on integer bits
- Applying left shift (
<<) and right shift (>>) operators correctly - Using the bitwise AND operator to test even or odd numbers
- Swapping two numbers without a temporary variable (using arithmetic or XOR)
- Finding the minimum of two numbers without an
ifstatement - Checking whether a number is negative using operator tricks
- Toggling a specific bit in an integer using XOR
Operators are the building blocks of every C expression. Arithmetic operators handle everyday math, bitwise operators let you manipulate individual bits, and relational/logical operators drive decision-making. The fastest way to internalize how each operator behaves — especially edge cases like integer division and shift overflow — is to write working code. This page collects 15 operator assignments, arranged from arithmetic fundamentals to bitwise tricks. Every assignment links to a full tutorial with the program code, sample output, and a line-by-line explanation.
🔹 Arithmetic Operators
Add, subtract, multiply, divide, and find remainders — the foundation of every C program.
- 1. Write a program to add two numbers using the '+' operator.
- 2. Write a program in C to subtract two numbers using the '-' operator.
- 3. Write a program in C to multiply two numbers using the '*' operator.
- 4. Write a program to divide two numbers using the '/' operator.
- 5. Write a program in C to find the remainder of two numbers using the '%' operator.
🔹 Bitwise & Shift Operators
Manipulate individual bits with AND, OR, XOR, and shift operators — essential for low-level and embedded programming.
- 6. Implement a program in C to perform bitwise AND on two numbers using the '&' operator.
- 7. Write a program in C to perform bitwise OR on two numbers using the '|' operator.
- 8. Write a program to perform bitwise XOR on two numbers using the '^' operator.
- 9. Write a program in C to perform bitwise left shift on a number using the '<<' operator.
- 10. Implement a program in C to perform bitwise right shift on a number using the '>>' operator.
🔹 Clever Operator Tricks
Combine operators in creative ways to solve classic problems — no if statements or temporary variables required.
- 11. Write a program in C to check if a number is even or odd using the bitwise AND operator.
- 12. Write a program in C to swap two numbers without using a temporary variable.
- 13. Write a program in C to find the minimum of two numbers without using the 'if' statement.
- 14. Write a program in C to check if a number is negative without using the 'if' statement.
- 15. Write a program in C to toggle a particular bit in a number using bitwise XOR.
How to Get the Most Out of These Assignments
Reading a solution is not the same as writing one. For each assignment, follow this three-step workflow:
- Attempt first. Open a blank editor and try to solve the problem using only the assignment description. Even if you get stuck, the act of trying cements the concept.
- Compare carefully. Open the solution page and compare your approach to the reference. Look for differences in operator precedence, type conversions, and edge cases like integer division.
- Re-implement from scratch. Close the solution page and write the program again without looking. This is the step most learners skip — and it's the one that actually builds fluency.
💡 Tip: Compile with gcc -Wall -Wextra -std=c11 so the compiler warns you about suspicious operator usage, such as mixing signed and unsigned types or shifting by too many bits.