Friday 1 December 2017

Csharp program integer Alternate Pattern


Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class program
{
    public static void Main()
    {
        int num, x, y, count = 0;
        Console.WriteLine("Enter the Number:");
        num = int.Parse(Console.ReadLine());
        x = num << 1;
        y = x ^ num;
        y = y + 1;
        while ((y / 2) != 0)
        {
            if (y % 2 != 0)
            {
                count++;
                break;
            }
            else
            {
                y = y / 2;
            }
        }
        if (count == 1)
        {
            Console.WriteLine("false");
        }
        else
        {
            Console.WriteLine("true");
        }
        Console.Read();
    }
}


Output:

Enter the Number: 100               
false


More C# Programs:


















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...