Users Online

· Guests Online: 10

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

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
 
Enter an integer :
120
120,480

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 2.12 seconds
14,588,032 unique visits