Learn with Vikas Suhag
VR Indian Wanderers Learn with Vikas Suhag Govt Jobs Free Chart Maker Stock Trekker Youtube Instagram RSS Feed
Program to demonstrate working of bitwise operators in C Language
Nov 26, 2021   Vikas Suhag

bitwise operators in C Language

#include <stdio.h>
void main()
{     
// a = 5(00000101), b = 9(00001001) // binary code
unsigned char a = 5, b = 9;
// The result is 00000001 =>1 decimal
printf("a = %d, b = %d\n", a, b);
printf("a&b = %d\n", a & b);  //          00000001
// The result is 00001101 =>13
printf("a|b = %d\n", a | b);
// The result is 00001100 => 12    
printf("a^b = %d\n", a ^ b);
// The result is 11111010=> 2+8+16+32+64+128=250
printf("~a = %d\n", a = ~a);
// The result is 00010010 =>2+16=18
printf("b<<1 = %d\n", b << 2); // 00100100 =4+32=36
// The result is 00000100 =>4
printf("b>>1 = %d\n", b >> 1); // 00000100
}

 

 


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Learn with Vikas Suhag Govt Jobs Free Chart Maker Stock Trekker Youtube Instagram RSS Feed
© 2025 Learn with Vikas Suhag. All Rights Reserved.