Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please i needed to a working pseudo code for converting any binary code to its equivalent decimal representation
Posted
Updated 4-Nov-22 18:01pm

1 solution

It's not complex: all you need to do is use the modulus and divide operators until there is no number left:

1) Set inp to binary number.
2) Set digit to inp modulus 10. Output digit
3) Set inp to inp divided by 10
4) If inp is not zero, repeat from (2)

The only complication is that this generates the digits in the wrong order: least significant first. So you will need to make your "Output Digit" cope with that, and probably store them in reverse order for output at the end. Exactly how you do that isn't complex, but I don't know how far you have got in your course, so I won't suggest anything - you have probably got an idea from the lecture that this was the homework from.
 
Share this answer
 
Comments
Genene Tise 28-Nov-22 14:54pm    
what is inp??
OriginalGriff 28-Nov-22 15:04pm    
After 9 years you expect me to remember? :laugh:

What do you y=think it might be?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900