EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

Write a program to convert the given binary number to a decimal number.

Source Code

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main (int argc, char *argv[])
{
  clrscr();
  int n,num,t,d=0;
  printf("\n Enter the binary number:");
  scanf("%d",&n);
10    num=n;
11    t=0;
12    while(n>0)
13    {
14          d+=pow(2,t)*(n%10);
15          n=n/10;
16          t++;
17    }
18    printf("\n The decimal equivalent of %d is %d",num,d);
19    getch();
20  }

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
#Return to Example Source Code