42 C Program to Multiply given Number by 4 using Bitwise Operators
Posted by Superadmin on December 23 2015 03:25:34
This C Program multiplies given number by 4 using bitwise operators. The bitwise operators are or, and, xor, not, left shift, right shift. Program uses left shift operator for this.
Here is source code of the C program to multiply given number by 4 using bitwise operators. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C program to multiply given number by 4 using bitwise operators
*/
#include

void main()
{
long number, tempnum;

printf("Enter an integer \n");
scanf("%ld", &number);
tempnum = number;
/* left shift by two bits */
number = number << 2;
printf("%ld x 4 = %ld\n", tempnum, number);
}



$ cc pgm62.c
$ a.out
Enter an integer
450
450 x 4 = 1800