|
-
October 6th, 2002, 02:15 PM
#1
[RESOLVED] Loop until condition met
Hi I'm trying to make a program that will convert a decimal number to binary. The problem I'm running into is making the loop that will continue out the math until it no longer needs to be carried out. The way im reaching the binary number from decimal is doing something like this:
if the number is say, 10, it would be
10 / 2 = 5 and 10 % 2 = 0
5 / 2 = 2 and 5 % 2 = 1
2 / 2 = 1 and 2 % 2 = 0 so 10 = 1010
I need the program to realize when the original number is now less than 2, so it knows to stop. The only thing I need to know is how to make the loop (I know what to put in the loop) and how to make the loop stop when the original number is less than 2. I tried using a do while but couldn't quite get the hang of it.
Help is always apprecitiated, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|