-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_operator.c
More file actions
27 lines (19 loc) · 721 Bytes
/
Copy path4_operator.c
File metadata and controls
27 lines (19 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<stdio.h>
int main()
{
int varOne = 7;
int varTwo = 2;
//Bitwise AND operator : boths bits 1 then 1
printf("Bitwise AND : %d\n" ,varOne&varTwo);
//Bitwise OR operator : 1 when either bit is 1
printf("Bitwise OR : %d\n" ,varOne|varTwo);
//Bitwise NOT operator : 0 to 1 and 1 to 0
printf("Bitwise NOT : %d\n" ,~varOne);
//Left Shift : equivalent to multiplication by 2pow(rightOperand)
printf("leftShift : %d\n" ,3<<1);
//Right Shift : equivalent to division by 2pow(rightOperand)
printf("rightShift : %d\n" ,3>>1);
//conditionalOperator
printf("outPut : %s" ,(varOne > varTwo) ? "varOne is greater" : "varTwo is greater");
return 0;
}