Tuesday, February 10, 2015

Binary to Decimal

/* Convert Binary number to Decimal number */ #include <stdio.h> int main() { long int binaryNumber, decimalNumber=0; long int j=1, remainder; printf("Enter any number any binary number: "); scanf("%ld", &binaryNumber); while (binaryNumber!=0) { remainder = binaryNumber%10; decimalNumber = decimalNumber + remainder*j; j = j*2; binaryNumber = binaryNumber / 10; } printf("Equivalent decimal value: %ld", decimalNumber); getch(); return 0; }

Share

& Comment

0 comments:

Post a Comment

 

Copyright © 2015 Code Fervor™ is a registered trademark.

Designed by Templateism By Naman Kumar