Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Automata Questions – 9
June 23, 2019
Q9. Convert Binary to Decimal by using the existing function. void binarytodecimal(number) { // Type your code here } void main() { int num; scanf(“%d”, &num); printf(“%d”, binarytodecimal(num); } Answer: void binarytodecimal(number) { int dval=0, base=1, rem; while(number > 0) { rem = number % 10; dval = dval + rem * base; num = number / 10; base = base * 2; } return dval; }
Login/Signup to comment