Answers for "c ^= operator"

C
1

c << operator

/*
 * The << operator shifts the bits of an integer a certan amount of steps to the left
 * So a << n means shifting the bits of a to the left n times
*/
#include <stdio.h>

int main() {
   int a = 10;  // 00001010 in binary
   int n = 2;

   printf("Result : %dn", a << n);
   // Result is 40 which is OO101000 in binary

   return 0;
}

// This also means that a << n is an equivalent to a * 2^n
Posted by: Guest on September-09-2021
4

c ? operator

/* The expression a ? b : c evaluates to b if the value of a is true, 
 * and otherwise to c
 */

// These tests are equivalent :

if (a > b) {
    result = x;
}
else {
    result = y;
}

// and

result = a > b ? x : y;
Posted by: Guest on September-16-2021

Code answers related to "C"

Browse Popular Code Answers by Language