This is a C Program to multiply given number by 4 using bitwise operators.

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 <stdio.h> 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); }

In this C program, we are reading the integer using ‘number’ variable, and assign the value of ‘number’ variable to ‘tempnum’ variable. The bitwise operators are, or, and, xor, not, left shift, right shift. The program uses left shift operator to the value of ‘number’ variable by two bits.

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

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Books in C Programming, Data-Structures and Algorithms

**If you find any mistake above, kindly email to [email protected]**

**Related Posts:**

- Practice BCA MCQs
- Apply for Computer Science Internship
- Apply for C Internship
- Watch Advanced C Programming Videos
- Check C Books