Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program that demonstrate the use of bitwise and, or, xor, ones compliment, left shift and right shift

Posted By: Vida Fischer     Category: C Programming     Views: 3619

Write a program that demonstrate the use of bitwise and, or, xor, ones compliment, left shift and right shift.

Code for Program that demonstrate the use of bitwise and, or, xor, ones compliment, left shift and right shift in C Programming

# include<stdio.h>
 
 main()
 {
   char c1,c2,c3;
   printf("ENTER VAULES OF  c1 and c2");
   scanf("%c,%c",&c1,&c2);
   c3 = c1 & c2; 
   printf("\n Bitwise AND  i.e. c1 & c2 = %c",c3);
   c3 = c1 | c2; 
   printf("\n Bitwise OR  i.e. c1 | c2 = %c",c3);
   c3 = c1 ^ c2; 
   printf("\n Bitwise  XOR i.e. c1 ^ c2 = %c",c3);
   c3 = ~c1; 
   printf("\n ones compliment  of  c1 = %c",c3);
   c3 =  c1<<2;
   printf("\n left shift by 2 bits c1 << 2 = %c",c3);
   c3 =  c1>>2;
   printf("\n right shift by 2 bits c1 >> 2 = %c",c3);
 }
 
  
Share: 



Vida Fischer
Vida Fischer author of Program that demonstrate the use of bitwise and, or, xor, ones compliment, left shift and right shift is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!