Docsity

Binary to decimal conversion in programing language, Lecture notes of Object Oriented Programming

Partial preview of the text

Download Binary to decimal conversion in programing language and more Lecture notes Object Oriented Programming in PDF only on Docsity!

#include <stdio.h> #include <math.h > int main() { int n; int d=0, r=0, s=0; printf("Enter a Binary Number\n"); scanf("%d", &n); while(n) { r = n % 10; if(r) { d = d + (pow(2, s) ); } n = n / 10; s++; } printf("Decimal number is "); printf("%d\n", d); return 0; }