18CS1002 PROGRAMMING FOR PROBLEM SOLVING LAB <REG. No.
>
Ex. No.
Bit wise operator <Title>
<Date of Exercise>
Aim
<Aim here>
To write a c program for bitwise operator and , or,not, Xor and shifting
Algorithm
<Algorithm here>
Flowchart
start
Get the input of a
and b
a &b
Calculate C=a&b
Program
<Program here> stop
#include <stdio.h>
main() {
Ex. No. | < Ex. Title>
18CS1002 PROGRAMMING FOR PROBLEM SOLVING LAB <REG. No.>
int a = 60; /* 60 = 0011 1100 */
int b = 13; /* 13 = 0000 1101 */
int c = 0;
c = a & b; /* 12 = 0000 1100 */
printf("Line 1 - Value of c is %d\n", c );
c = a | b; /* 61 = 0011 1101 */
printf("Line 2 - Value of c is %d\n", c );
c = a ^ b; /* 49 = 0011 0001 */
printf("Line 3 - Value of c is %d\n", c );
c = ~a; /*-61 = 1100 0011 */
printf("Line 4 - Value of c is %d\n", c );
c = a << 2; /* 240 = 1111 0000 */
printf("Line 5 - Value of c is %d\n", c );
c = a >> 2; /* 15 = 0000 1111 */
printf("Line 6 - Value of c is %d\n", c );
Output
Ex. No. | < Ex. Title>
18CS1002 PROGRAMMING FOR PROBLEM SOLVING LAB <REG. No.>
<Output snapshot here>
Result
Thus the bitwise operators c programming is verified successfully.
Ex. No. | < Ex. Title>