/* C Program to demonstrate example of left shift (<<) operator.
    
Left Shift Operator (<<) is a bitwise operator, which perform operation on bits.
It is used to shift given number of bytes in the left and inserts 0’s in the right.

Binary of 0xFF in (in 4 bytes format) - 0000 0000 1111 1111.

After 2 bytes left shift (in 4 bytes format) – 0000 0011 1111 1100,
which is equivalent of 0x03FC.

*/

#include <stdio.h>

int main()
{

    unsigned int num = 0xff;

    printf("\nValue of num = %04X before left shift.", num);

    /*shifting 2 bytes left*/
    num = (num << 2);
    printf("\nValue of num = %04X after left shift.", num);

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: