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
long number, tempnum;
printf("Enter an integer \n");
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
Sanfoundry Global Education & Learning Series – 1000 C Programs.