Trying to make an algorithm to convert Dec to Bin

Trying to make an algorithm to convert Dec to Bin,
need to use an array with a decreasing index to give out the number is the right order,
don't seem to be able to make it work.

How do I set the index properly? and how do I initiate the array to 0 when I-m converting small numbers?

try N>-1 or N=>0 instead of N!=0.

Uhhh, no that works,
It's the For that-s not working

ignore this output bin[i], don't you wanna return the whole array?

what language/program is this?

Its called pseudo-code. Not language specific. Its meant to be a high-level human-readable format from which we can extrapolate that idea and translate it into any language form we want.

Well not really at that specific point,
I just wanted to check the content of the array, isn't that how you do it?
What I want to do at that point is just make another for cycle to print out Bin[i] in the right order.
But I can't figure out what I'm doing wrong with the For conditions.

This, also gives out different codes translation for the algorithm.
It's to get familiar with the logic.

Your alg doesn't make sense, the for it's not necessary, you overwrite bin[i] every time without changing the index
i = (int)(log(N)/log(2));
do{
bin[i] = N%2;
N /= 2;
--i;
}while(N!=0)


Or better

arrayDim = (int)(log(N)/log(2));
for(i=arrayDim;i

If you have an array of five (and then a decimal number under 2^5 = 128), just use five instead of log2

Hope it helps, if I'm wrong sorry, shame on me

it's not fucking pseudocode if you can execute it you goddamn moron

otherwise the syntax would be irrelevant, which it obviously isnt.

>the for it's not necessary, you overwrite bin[i] every time

Fuck, original idea was to put the values of Bin in an array (Bin[i]) and then use another array to print it straight.
I forgot the for was supposed to be for the index of the second array not Bin[i].
Maybe I can fix it.

It's a pseudocode with a syntax.

What's your level with programming?

I'm starting from scratch, trying to figure shit out

Modularize your mind, make small step, don't rush a problem. You need to simplify everything. Personally I think that you must not bother with pseudocode, just use an interactive programming language and start from there, something like python that teaches you indentation too. Then jump on C or something more low level. Then try some high level language like java.
If you do this maybe you'll end programming something useful, or maybe not, like me, who like fractran.
Ps learn algebra
Pss install gentoo, unironically

here you go

Funny but it works.

>Ps learn algebra
At the moment, I'm thinking about giving up and find a dead end job and stop trying to be happy.

>Personally I think that you must not bother with pseudocode
We just used it for a few weeks to wrap our mind around the basic logic of sequence, selection and iteration,
next step is grabbin either arduino or raspberry and realize a small project, either with C or phyton.

Convert to hex then convert to bin. It'll be easier and basically what computers do.

>implying you can't be happy in a dead end job

Is this "pseudocode" an inside joke?

can someone explain? google doesn't give me an actual application

I think I would, I enjoy working with my hands more than with my brain.
But I'm not as educated as my intelligence would require me to be, and that makes me unhappy, so I'm trying to fix that.

It's a simple to read code that's used to explain real code to people like me.

Just find happiness in what you have/are, life it's too short.
If you think that dropping everything it's good for you, then go for it, but usually the sufference and the hard work repays, maybe you'll not become richer, but you'll be a better person.

It's about the journey, not the destination

Did that once already, dropped out of EE years ago (HS).
it made me happier in the sense that I've found more immediate gratification, but I sure as hell wasn't going anywhere.
I already have some options if I manage to finish the 3 years to get my degree, so I shuld really stick to it.

I'm also afraid I won't be able to keep up with this ever evolving field once i'm out, and realize that the skill I'm acquiring won't be sufficient.

I understand, I'm at the edge of dropping my master degree in physics, but who knows, we will see... ㄟ(ツ)ㄏ

you can put it in front of a ton of things.
specifically pseudocode means it is meant as a demonstration of how you would write the code, but it is not any real language, so you can't run it anywhere.
It is often used for algorithms and when you explain stuff.

If he is trying to learn binary, why not use binary operators?
arrayDim = static_cast(log(N)/log(2));
for(i=arrayDim;i

but obviously OP is compiling and or running it otherwise he wouldn't know that it doesn't work.

sooooo...?

It's a pseudo pseudocode