+ 7

Binary to decimal in C

i am stuck with my binary to decimal program in C. can u help me to solve

1st Feb 2018, 4:45 PM
Nandini Srinivasan
Nandini Srinivasan - avatar
8 Answers
+ 8
Thank u my friend:-)
1st Feb 2018, 7:05 PM
Nandini Srinivasan
Nandini Srinivasan - avatar
+ 8
👍
1st Feb 2018, 7:09 PM
Nandini Srinivasan
Nandini Srinivasan - avatar
+ 7
actually i dnt have link.
1st Feb 2018, 6:47 PM
Nandini Srinivasan
Nandini Srinivasan - avatar
+ 7
do u hav a ans with u Mr.Ram Krishna
1st Feb 2018, 6:47 PM
Nandini Srinivasan
Nandini Srinivasan - avatar
+ 4
I hope this will works
1st Feb 2018, 7:06 PM
RAM KRISHNA
RAM KRISHNA - avatar
+ 3
hiii nandhini
1st Feb 2018, 6:44 PM
RAM KRISHNA
RAM KRISHNA - avatar
+ 3
#include <stdio.h> void main() { int num, binary_val, decimal_val = 0, base = 1, rem; printf("Enter a binary number(1s and 0s) \n"); scanf("%d", &num); binary_val = num; while (num > 0) { rem = num % 10; decimal_val = decimal_val + rem * base; num = num / 10 ; base = base * 2; } printf("Its decimal is = %d \n", decimal_val); }
1st Feb 2018, 7:01 PM
RAM KRISHNA
RAM KRISHNA - avatar