
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document has the program code that will convert input if it is in binary then convert it into decimal
Typology: Lecture notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

#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; }