Enter an integer : 120 120,480
Users Online
· Guests Online: 10
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Multiply Number by 4 using Bitwise Operators
C# Program to Multiply Number by 4 using Bitwise Operators
This is a C# Program to multiply given number by 4 using bitwise operators.
Problem Description
This C# Program Multiplies given Number by 4 using Bitwise Operators.
Problem Solution
Here The bitwise operators are or, and, xor, not, left shift, right shift. Program uses left shift operator for this.
Program/Source Code
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(); } } }
Program Explanation
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.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.