Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int binary_to_decimal(char bin[]){
- int index, sum;
- int accumulator = 64;
- for(index = 0; index < 8; index++) {
- if(accumulator > 0){
- if(bin[index] == '1'){
- sum = sum + accumulator;
- accumulator = accumulator / 2;
- }
- else
- accumulator = accumulator / 2;
- }
- }
- printf("Num: %d", sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement