Thursday, October 24, 2013

Write a C# Program to convert Binary to Decimal

1:03 PM


Write a C# Program to convert Binary to Decimal


using System;
using System.Collections.Generic;
using System.Text;

namespace Program
{
class Program
{
static void Main(string[] args)
{
int num, binary_val, decimal_val = 0, base_val = 1, rem;
Console.Write("Enter a Binary Number(1s and 0s) : ");
num = int.Parse(Console.ReadLine()); /* maximum five digits */
binary_val = num;
while (num > 0)
{
rem = num % 10;
decimal_val = decimal_val + rem * base_val;
num = num / 10 ;
base_val = base_val * 2;
}
Console.Write("The Binary Number is : "+binary_val);
Console.Write("\nIts Decimal Equivalent is : "+decimal_val);
Console.ReadLine();
}
}
}




-----------------------------------------------
C# Program to Perform Binary to Decimal 
Converting from Binary and Decimal in C# C sharp
binary to decimal
Binary To Decimal Conversion In C#
PROGRAM FOR BINARY TO Decimal CONVERSION C#

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top