+ 2
I'm very new to coding, trying out C# as the first one. Could anyone please tell me what am I doing wrong?
I saw one of the challenges and tried converting 5 in decimal to 5 in binary. I'm not really expecting anyone to read or respond to this but if you do - thank you very much. Apologies for the incredibly bad coding I'm really unsure of what I'm doing. https://code.sololearn.com/cgCLppyYU6q3/?ref=app
4 Answers
+ 3
Here is a simple example in C (I am mot familiar with C# unfortunately) for decimal to binary conversion:
https://www.javatpoint.com/c-program-to-convert-decimal-to-binary
Basically the conversion needs to be done in a loop rather than how you did it.
+ 2
Oh, thank you. I thought about that but I haven't even got to loops yet. I was just wondering if I could do anything like that. I guess I was wrong, thank you for replying.
+ 1
For a small number, like your example 5, you can actually can do the loop steps manually (adding some IF conditions) but it would be only applicable to that number, if you change the number you will need to adapt the code. That maybe is a good way of practicing but in real life you would use a loop for resolving such exercise.