c 3c 3c operator

Solutions on MaxInterview for c 3c 3c operator by the best coders in the world

showing results for - "c 3c 3c operator"
Maria José
26 Aug 2019
1/*
2 * The << operator shifts the bits of an integer a certan amount of steps to the left
3 * So a << n means shifting the bits of a to the left n times
4*/
5#include <stdio.h>
6
7int main() {
8   int a = 10;  // 00001010 in binary
9   int n = 2;
10
11   printf("Result : %d\n", a << n);
12   // Result is 40 which is OO101000 in binary
13
14   return 0;
15}
16
17// This also means that a << n is an equivalent to a * 2^n
Elisa
09 Oct 2016
1// | is the binary "or" operator
2// a |= b is equivalent to a = a|b
3
4#include <stdio.h>
5
6int main() {
7   int a = 10;  // 00001010 in binary
8   int b = 6;   // 00000110 in binary
9
10   printf("Result : %d\n", a |= b);
11   // Result is 14 which is OOOO111O in binary
12
13   return 0;
14}