C program to convert a binary number to an equivalent decimal number
kw.c
#include<stdio.h>intmain(){longn;intr,dn=0,i=1;printf("———————————————————————————————————————————");printf("\nProgram to convert a binary number to decimal");printf("\n———————————————————————————————————————————");printf("\nEnter the binary number ");scanf("%ld",&n);while(n!=0){r=n%10;dn=dn+r*i;i=i*2;n=n/10;}printf("\nEquivalent decimal number is %d",dn);printf("\n———————————————————————————————————————————\n");return0;}
Output
kodingwindow@kw:~$ gcc kw.c kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to convert a binary number to decimal
———————————————————————————————————————————
Enter the binary number 11111111
Equivalent decimal number is 255
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?