Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Bitwise Operations | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 21 of 50

·c

Bitwise Operations

9 mins

Course progress42%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `x & 0x1F` extracts the low‑order 5 bits.
  • `x | 0x80` sets the high bit.
  • `x ^ y` toggles bits that differ.
  • `x << 1` is equivalent to `x * 2` for unsigned values.

Bitwise operators work directly on the binary representation of integers.

OperatorMeaning
&AND – set bits that are 1 in both operands
``
^XOR – set bits that are 1 in exactly one operand
~NOT – flips every bit
<<Left shift – multiplies by 2ⁿ (adds zeros on the right)
>>Right shift – divides by 2ⁿ (implementation‑defined for signed)

Common uses: flags, masks, low‑level device drivers, graphics.

Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonEnumerations (`enum`)Continue to lesson 22Function PointersBack to C Programming Fundamentals curriculum