#Binary C Track
29 messages · Page 1 of 1 (latest)
Which track? What have you tried so far?
I tried nothing for the moment
because first i have to use an int
I don't see how I can convert directly from a string.
i have a doubt
i make this
for the moment
I think it makes more sense to use an integer rather than a string.
In general please share codeblocks, not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests and http://bit.ly/howto-ask
But more importantly what track is this for? Exercism offers 77 tracks so letting us know which one you’re working on will help us help you.
Its C track
Can you update the thread title please to reference the track for increased visibility?
The instructions say to do it from first principles. How would you convert that by hand using only paper and pencil?
Okay no problem
Binary C Track
I understand how to convert from binary to decimal
But i dont know how to do this in C with a string
Start by writing out the steps in English. Then, if there's any specific bit you can't figure out how to translate from English to C, you can ask about that specific step, vs saying you don't know how to do any of it.
Which part of the conversion are you having trouble with?
Finally i understand how to proceed
we have a string but its an array
Yes. That's how C strings work 😉 A string is a series (array) of characters.
I have to write a C program that converts a binary string into a decimal number. To do that, I’ll first check if the string only contains '0' and '1', and then I’ll use the position of each bit to compute its corresponding power of 2 and add it to the result.
thank you
Sounds like a plan. For bonus points, try to solve it without doing any exponent operators 🙂