Operator Assignments in C — 15 Programs with Solutions
  • Twitter
  • Facebook
  • Snapchat
  • Instagram

Operators Assignments in C Language with Explanation and Solutions

📑 Jump to a category:
  • Arithmetic Operators (1–5)
  • Bitwise Operators (6–10)
  • Operator Tricks (11–15)
  • Previous / Next Topic
📚 What you'll practice across these 15 assignments:
  • 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 if statement
  • 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.

Operators assignments in C language — arithmetic, bitwise, and shift operator exercises with step-by-step solutions.

🔹 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:

  1. 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.
  2. 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.
  3. 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.

📖 Related Tutorials

  • Arithmetic Operators in C
  • Assignment Operators in C
  • Increment and Decrement Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Other Operators
  • Operators Multiple-Choice Questions
  • Operators FAQ

Previous Topic: -->> Basic Assignments in C   ||   Next topic: -->> Conditional Statements Assignments in C


C Language

  • Home
  • Why C Language
  • History of C Language
  • Applications of C Language
  • Introduction To C
    • What is Program?
    • Structure of C Program
    • Working Of C Program
    • CHARACTER SET
    • VARIABLES AND IDENTIFIERS
    • BUILT-IN DATA TYPES
    • OPERATORS AND EXPRESSIONS
    • CONSTANTS AND LITERALS
    • SIMPLE ASSIGNMENT STATEMENT
    • BASIC INPUT/OUTPUT STATEMENT
    • SIMPLE 'C' PROGRAMS
    • Assignments
  • Operators in C Programming
    • Arithmetic Operators
    • Assignment Operators
    • Increment and Decrement Operators
    • Relational Operators
    • Logical Operators
    • Bitwise Operators
    • Other Operators
    • Assignments
  • CONDITIONAL STATEMENTS
    • DECISION MAKING WITHIN A PROGRAM
    • CONDITIONS
    • IF STATEMENT
    • IF-ELSE STATEMENT
    • IF-ELSE LADDER
    • NESTED IF-ELSE
    • SWITCH CASE
    • Assignments
  • LOOPS STATEMENTS
    • Introduction to Loops
    • GO TO Statement
    • Do while Loop
    • While Loop
    • Nested While Loop
    • Difference Between While and Do while
    • Difference Between Goto and loop
    • while loop assignments
    • C FOR Loop
    • C For loop examples
    • Nested for loop
    • Nested for loop examples
    • Infinite while Loops
    • Infinite for Loops
    • Continue in Loops
    • break in Loops
    • difference while do..while & for
    • Assignments
  • Arrays
    • One Dimensional Array
    • Declaring 1D Arrays
    • Initilization of 1D arrays
    • Accessing element of one 1D Array
    • Read and Display 1D Arrays
    • Two Dimensional Arrays
    • Declare 2D Arrays
    • Read and Display 2D Arrays
    • Assignments/Examples
  • Functions
    • Introduction
    • Need For User-Defined Function
    • Multiple Function Program
    • Modular Programming
    • Elements Of User Defined Function
    • Function Definition
    • Function Declaration
    • Types of functions
    • Nesting of Function
    • Recursion
    • Passing Array To Functions
    • Scope,Visibility and Lifetime of Variables
    • Assignments
  • Structure
    • Introduction
    • Array vs Structure
    • Defining Structure
    • Declaring Structure Variables
    • Type Defined Structure
    • Accessing Structure Members
    • Structure Initilization
    • Copying & Comparing Structure Variables
    • Array of Structure
    • Arrays Within Structure
    • Structures Within Structures
    • Structures and Functions
    • Structure Examples/Assignments
  • Union
    • Define Union
    • Create and use Union
    • Difference Between Structure and Union
    • Union Examples
    • Union FAQ
  • Pointers
    • What Are Pointers In C?
    • How Do We Use Pointers In C?
    • Declaration Of A Pointer
    • The Initialization Of A Pointer
    • Syntax Of Pointer Initialization
    • Use Of Pointers In C
    • The Pointer To An Array
    • The Pointer To A Function
    • The Pointer To A Structure
    • Types Of Pointers
    • The Null Pointer
    • The Void Pointer
    • The Wild Pointer
    • The Near Pointer
    • The Huge Pointer
    • The far Pointer
    • dangling pointer
    • Accessing Pointers- Indirectly And Directly
    • Pros Of Using Pointers In C
    • Cons Of Pointers In C
    • Applications Of Pointers In C
    • The & Address Of Operator In C
    • How To Read The Complex Pointers In C?
    • Practice Problems On Pointers
  • File Processiong
    • File Handling In C
    • Types Of Files In C
    • Operations Done In File Handling
    • File Examples
    • Binary Files
    • count words,lines in a file
    • Copy files
    • Update File
    • count vowels in a file
  • Preprocessor
    • Macro substitution division
    • File Inclusion
    • Conditional Compilation
    • Other directives
    • Examples
  • Dynamic Memory Allocation
    • malloc
    • calloc
    • free
    • realloc
    • Examples
  • Storage Classes
  • Graphics
  • Frequently Asked Interview Questions (FAQ)
    • Introduction To C FAQ
    • Operators FAQ
    • Conditional Statements FAQ
    • Loops FAQ
    • Arrays FAQ
    • Function FAQ
    • Structure FAQ
    • Pointers FAQ
    • Files FAQ
    • Storage classes FAQ
    • Dynamic Memory FAQ
  • Programs/Assignments
    • Introduction To C
    • Operators
    • Conditional Statements
    • Loops
    • Arrays
    • Function
    • Structure
    • Pointers
    • Files
    • Storage classes
    • Dynamic Memory
  • Case Studies
  • Multiple Choice Questions
    • Introduction To C MCQ
    • Operators MCQ
    • Conditional Statements MCQ
    • Loops MCQ
    • Arrays MCQ
    • Function MCQ
    • Structure MCQ
    • Pointers MCQ
    • Files MCQ
    • Storage classes MCQ
    • Dynamic Memory MCQ
    • More MCQ

Get in touch

  • tech2dsm@gmail.com

© Sankalan Data Tech. All rights reserved.