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.
Here 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 executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Multiply given Number by 4 using Bitwise Operators */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication { class Program { static void Main(string[] args) { int number, tempnum; Console.WriteLine("Enter an integer :"); number = int.Parse(Console.ReadLine()); tempnum = number; number = number << 2; Console.WriteLine("{0},{1}", tempnum, number); Console.ReadLine(); } } }
In this C# program, we are reading an integer value using ‘number’ variable. Binary Left Shift Operator is used to move the value of left operands by the number of bits specified by the value of right operand. Print the multiplied value of the given number.
Enter an integer : 120 120,480
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Apply for C# Internship
- Check MCA Books
- Check C# Books