programming-examples/c-sharp/Mathematics/C# Program to Find Power of 2 using Bitwise Operator.cs

29 lines
558 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Find Power of 2 using Bitwise Operator
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace example
{
internal class Program
{
private static void Main(string[] args)
{
int num;
Console.Write("Enter a number:");
num = Convert.ToInt32(Console.ReadLine());
bool result = ((num & -num) == num);
Console.WriteLine(result);
Console.ReadLine();
}
}
}
/*
Enter a number:16
True