Program to Convert a binary number to a decimal number

#include<stdio.h>
#include<conio.h>

int main()

{

int n, nsave, rem, d, j = 1, decimal = 0;
printf(“Enter the number in binary”);
scanf_s(“%d”, &n);
nsave = n;
while (n>0)
{
rem = n%10;
d = rem*j;
decimal= decimal+d;
j = j * 2;
n =n/ 10;
}
printf(“Binary number = %d, Decimal number = %d\n”, nsave, decimal);

return 0;
}

 

One comment

  1. Hiya very nice web site!! Guy .. Excellent .. Amazing .. I’ll bookmark your blog and take the feeds additionally…I am glad to seek out so many helpful info here within the publish, we’d like work out more techniques on this regard, thank you for sharing. . . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *